コード例 #1
0
ファイル: server.py プロジェクト: rainandwind1/ffai_2019
def create():
    data = json.loads(request.data)
    bot_list = api.get_bots()
    # make_bot or Agent depending on choice... (unknown name => human)
    homePlayer = data['game']['home_player']
    if homePlayer in bot_list:
        homeAgent = make_bot(homePlayer)
    else:
        homeAgent = Agent("Player 1", human=True)

    awayPlayer = data['game']['away_player']
    if awayPlayer in bot_list:
        awayAgent = make_bot(awayPlayer)
    else:
        awayAgent = Agent("Player 1", human=True)

    game = api.new_game(data['game']['home_team_name'],
                        data['game']['away_team_name'], homeAgent, awayAgent)
    return json.dumps(game.to_json())
コード例 #2
0
import ffai.web.server as server
import ffai.web.api as api
from ffai.ai.registry import make_bot
from ffai.core.model import Agent

# Import this to register MyScriptedBot with id 'scripted'
import examples.scripted_bot_example

# Create some games
api.new_game(home_team_id="orc-1",
             away_team_id="human-1",
             home_agent=make_bot("random"),
             away_agent=Agent("Player 2", human=True))

api.new_game(home_team_id="orc-1",
             away_team_id="human-1",
             home_agent=make_bot("scripted"),
             away_agent=Agent("Player 2", human=True))

api.new_game(home_team_id="human-1",
             away_team_id="human-2",
             home_agent=Agent("Player 1", human=True),
             away_agent=Agent("Player 2", human=True))

# Run server
server.start_server(debug=True, use_reloader=True)
コード例 #3
0
ファイル: server.py プロジェクト: efebozkir/ffai
def create():
    data = json.loads(request.data)
    game = api.new_game(data['game']['home_team_id'], data['game']['away_team_id'])
    return json.dumps(game.to_json())
コード例 #4
0
#!/usr/bin/env python3

import ffai.web.server as server
import ffai.web.api as api
from ffai.ai.registry import make_bot
from ffai.core.model import Agent

# Import this to register bots
import sagelingbot

api.new_game(home_team_id="orc-1",
             away_team_id="human-1",
             home_agent=make_bot("SagelingBot"),
             away_agent=make_bot("SagelingBot"))

# Run server
server.start_server(debug=True, use_reloader=False)