예제 #1
0
파일: run_env.py 프로젝트: derNarr/ffai
def run_game(nbr_of_games, enable_forward_model):
    config = ffai.load_config("gym-11")
    config.fast_mode = True
    ruleset = ffai.load_rule_set(config.ruleset)
    home = ffai.load_team_by_filename("human", ruleset)
    away = ffai.load_team_by_filename("human", ruleset)
    away_agent = Agent("Human 1", human=True, agent_id=1)
    home_agent = Agent("Human 2", human=True, agent_id=2)

    seed = 0
    random_agent = ffai.make_bot('random')
    random_agent.rnd = np.random.RandomState(seed)

    for _ in range(nbr_of_games):
        game = Game(seed, home, away, home_agent, away_agent, config)
        game.init()
        if enable_forward_model:
            game.enable_forward_model()
        while not game.state.game_over:
            game.step(random_agent.act(game))
예제 #2
0
# Register MyScriptedBot
ffai.register_bot('scripted', MyScriptedBot)

if __name__ == "__main__":

    # Uncomment to this to evaluate the bot against the random baseline

    # Load configurations, rules, arena and teams
    config = ffai.load_config("bot-bowl-iii")
    config.competition_mode = False
    config.pathfinding_enabled = True
    # config = get_config("gym-7.json")
    # config = get_config("gym-5.json")
    # config = get_config("gym-3.json")
    ruleset = ffai.load_rule_set(config.ruleset, all_rules=False)  # We don't need all the rules
    arena = ffai.load_arena(config.arena)
    home = ffai.load_team_by_filename("human", ruleset)
    away = ffai.load_team_by_filename("human", ruleset)

    # Play 10 games
    for i in range(10):
        home_agent = ffai.make_bot('scripted')
        home_agent.name = "Scripted Bot"
        away_agent = ffai.make_bot('random')
        away_agent.name = "Random Bot"
        config.debug_mode = False
        game = ffai.Game(i, home, away, home_agent, away_agent, config, arena=arena, ruleset=ruleset)
        game.config.fast_mode = True

        print("Starting game", (i+1))
예제 #3
0
#!/usr/bin/env python3

import ffai
import ffai.ai.bots.testbots


# Load competition configuration for the bot bowl
config = ffai.load_config('bot-bowl-ii')

# Get ruleset
ruleset = ffai.load_rule_set(config.ruleset, all_rules=False)

# Load team to be used
human_team_a = ffai.load_team_by_filename('human', ruleset)
human_team_b = ffai.load_team_by_filename('human', ruleset)

# Random vs. Random
competition = ffai.Competition('MyCompetition', competitor_a_team=human_team_a, competitor_b_team=human_team_b, competitor_a_name='random', competitor_b_name='grodbot', config=config)
results = competition.run(num_games=2)
results.print()
예제 #4
0
process_a.start()
token_b = secrets.token_hex(32)
print(f"Token B: {token_b}")
process_b = Process(target=run_agent, args=('random', 5200, token_b))
process_b.start()

# Specify the host running the agents (localhost)
hostname = socket.gethostname()

# Make sure the agents are running
time.sleep(2)

# Load configurations, rules, arena and teams
config = ffai.load_config("bot-bowl-ii")

ruleset = ffai.load_rule_set(config.ruleset)
arena = ffai.load_arena(config.arena)
team_a = ffai.load_team_by_filename("human", ruleset)
team_b = ffai.load_team_by_filename("human", ruleset)

# Make proxy agents
client_a = PythonSocketClient("Player A", 'niels-mac', 5100, token=token_a)
client_b = PythonSocketClient("Player B", 'niels-mac', 5200, token=token_b)

# Run competition
competition = ffai.Competition(client_a,
                               client_b,
                               team_a,
                               team_b,
                               config=config,
                               ruleset=ruleset,