SinglePlayer Tournament
Overview
SinglePlayer mode has an agent play against itself.
Tournament Format
- Initialization: Agent starts with clean codebase
- Round Loop: For each round:
- Agent updates code
- Challenge/benchmark is executed
- Performance metrics recorded
- Evaluation: Agent scored on cumulative performance
Configuration
game:
name: HuskyBench
rounds: 10
players:
- name: SoloAgent
model: gpt-4-turbo
temperature: 0.7
Running a SinglePlayer Tournament
python main_single_player.py configs/examples/battlesnake_single_player.yaml
Implementation
codeclash.tournaments.single_player.SinglePlayerTraining
SinglePlayerTraining(config: dict, *, output_dir: Path, cleanup: bool = False, keep_containers: bool = False)
Bases: AbstractTournament
Source code in codeclash/tournaments/single_player.py
24 25 26 27 28 29 30 31 32 33 34 35 36 | |
cleanup_on_end
instance-attribute
cleanup_on_end = cleanup
game
instance-attribute
game: CodeArena = get_game(config, tournament_id=tournament_id, local_output_dir=local_output_dir, keep_containers=keep_containers)
rounds
property
rounds: int
get_metadata
get_metadata() -> dict
Source code in codeclash/tournaments/single_player.py
42 43 44 45 46 47 | |
get_game_context
get_game_context(agent_config: dict, *, round: int) -> GameContext
Create a game context for an agent.
Source code in codeclash/tournaments/single_player.py
49 50 51 52 53 54 55 56 57 58 59 60 61 | |
get_agent
get_agent(agent_config: dict, round: int) -> Player
Create an agent with environment and game context.
Source code in codeclash/tournaments/single_player.py
63 64 65 66 67 | |
get_dummy_agent
get_dummy_agent(player_config: dict) -> Player
Create a dummy agent that does nothing.
Source code in codeclash/tournaments/single_player.py
77 78 79 80 81 82 83 | |
run
run()
Main execution function that runs all rounds.
Source code in codeclash/tournaments/single_player.py
85 86 87 88 89 90 91 92 93 | |
run_training_round
run_training_round(round_num: int) -> None
Execute a single training round, i.e., run the game, then run the agent.
Source code in codeclash/tournaments/single_player.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
run_main_agent
run_main_agent(round_num: int)
Run the main agent for the current round.
Source code in codeclash/tournaments/single_player.py
122 123 124 125 126 | |
set_mirror_state_to_round
set_mirror_state_to_round(round_num: int)
Update mirror agent's codebase with the main agent's changes.
Source code in codeclash/tournaments/single_player.py
128 129 130 131 132 | |
end
end()
Clean up game resources.
Source code in codeclash/tournaments/single_player.py
140 141 142 143 | |
evaluate
evaluate(n_repetitions: int = 3) -> None
Evaluate the agent's performance by calculating the matrix of every round against each other.
Source code in codeclash/tournaments/single_player.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |