Giter Site home page Giter Site logo

ailadderservice's Introduction

AILadderService

The StarCraft2 AI ladder service

页面设计

参照 http://sc2ai.net

分为

  1. Home
  2. Ladder Seasons
  3. Learning
  4. Information

等几个页面,除了Ladder Seasons以外全部为静态页面

服务流程设计


新建账号

  1. 服务层接受到前端的新建账号请求
  2. 服务层对新建账号请求参数进行验证
  3. 将新账号信息存储于数据库中
  4. 在文件系统中新建账号名对应的文件夹,用于放置bot文件
  5. 服务层将bot文件存放到相应的文件夹中,将bot的用户信息,路径信息,提交时间等存放到数据库中
  6. 将bot加入比赛池

更新bot

  1. 服务层接受到上传bot的请求
  2. 服务层读取session信息,进行验证
  3. 服务层将bot文件存放到相应的文件夹中,覆盖之前的bot,将相应信息存放到数据库中

比赛

  1. 启动一个循环线程,不断从比赛池中随机取出两个bot,进行比赛
  2. 比赛完成之后,将和录像地址信息存入数据库,将比赛录像存入比赛录像文件夹,起名为A_B_时间戳
  3. 更新比赛结果信息,计算胜率和天梯得分

天梯页面

  1. 服务层接受到获取天梯信息的请求
  2. 获取所有用户数据,并打包返回

获取单个用户比赛结果页面

  1. 服务层接受到获取replay的post请求
  2. 根据post中的用户名,去往比赛录像数据表中搜索对应用户名的所有比赛记录,包括对手名称,对战种族,地图和比赛结果,并打包返回

获取replay接口

  1. 服务层接受到获取replay的请求
  2. 根据比赛ID信息,去往比赛录像数据表中获取对应比赛ID的replay储存地址
  3. 服务层读取储存地址的文件,以文件的形式Response

接口详细设计

失败返回

接口调用失败统一返回如下json,其中包括如下对象:

名称 类型 是否必须 描述
err_no int 错误的id
message string 错误信息

例子:

{
    "err_no":1,
    "message":"Cannot find the replay file."
}

新建账号

方法:post

地址:/sign_up

content-type:form-data

参数:

名称 类型 是否必须 描述
email string 用户的Email,在服务层对其进行格式校验
username string 用户名
password string 用户的密码
botName string 用户提交bot的名字
botType int bot类型,考虑支持c++和python,暂时只支持c++,0:c++,1:python
race int bot种族,0T1P2Z
description string 对bot的描述
bot multipartFile bot文件(json文件)现在暂时支持通过commandcenter读取配置文件对战,未来考虑使用dll或so文件

例子:

"email":"[email protected]",
"username":"bcd",
"password":"123",
"botName":"abc",
"botType":0,
"race":1,
"description":"hahaha",
"bot":multipart file

返回值:

名称 类型 是否必须 描述
success int 值固定为0

更新bot

方法:post

地址:/update

content-type:form-data

参数:

名称 类型 是否必须 描述
username string 用户名
password string 用户密码
bot multipartFile 用户bot文件

返回值:

名称 类型 是否必须 描述
success int 值固定为0

天梯页面

方法:get

地址:/ladder

参数:

名称 类型 是否必须 描述
season int 赛季

例子:

sc2.com/index?season=1

返回值:

名称 类型 是否必须 描述
botName string bot的名字
username string 用户名
race int 种族
matches int 比赛场次
wins int 胜利次数
winRate float 胜率

例子: [ { "botName":"abc", "username":"bcd", "race":"Protoss", "matches":1, "wins":0, "winRate":0.0 } ]

获取单个用户比赛结果页面

方法:post

地址:/view_result

类型:application/json

参数:

名称 类型 是否必须 描述
season int yes season
username string 用户名

返回值:

名称 类型 是否必须 描述
time string 比赛时间
opponentBot string 对手名称
race string 对手种族
Map string 比赛地图
result string 比赛结果

获取replay

方法:post

地址:/get_replay

类型:application/json

名称 类型 是否必须 描述
username string 用户名
replayId int replay的Id

返回:multipart file

数据库设计

账号信息表

名称 类型 是否必须 描述
id int 用户id,auto increment
email char(100) 用户email
username char(30) yes user name
password char(50) yes password.md5 + salt
bot_name char(30) yes bot name
bot_type int yes bot type
update_time Date yes update bot的时间
race int yes race
description varchar no description
bot_path char(50) yes file path of bot

比赛队列

名称 类型 是否必须 描述
username char(30) yes username, pk
bot_name char(50) yes bot name
bot_path char(50) yes bot path

比赛结果

名称 类型 是否必须 描述
id int yes auto increment
username_A
username_B
bot_name_A char(50) yes 其中一人的bot的名字
bot_name_B char(50) yes 另外一人的bot的名字
win int yes 0:平局,1:A胜利,-1:B胜利
replay_path char(50) yes 录像的保存路径,录像名字:A bot名+B bot名+时间戳

赛季记录表

名称 类型 是否必须 描述
season int yes 第几赛季
username string yes username
bot_name char(50) yes bot的名字
matches int yes 比赛场数目
wins int yes 胜利数
win_rate float yes 胜率

ailadderservice's People

Contributors

jianwang-mpi avatar biug avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

ailadderservice's Issues

几个要修改的问题

  1. 提交表单检测,检测dll文件
  2. 做管理员页面,控制游戏进行,星际二和提交网站分离
  3. 解决同一个用户多次注册失败的问题

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.