PvP Tournament
Player-versus-player tournament where multiple agents compete head-to-head.
Overview
PvP tournaments pit multiple agents against each other in competitive matches. Agents earn points by winning rounds, and the agent with the most cumulative points wins the tournament.
Tournament Format
- Initialization: All agents start with clean codebases
- Round Loop: For each round:
- All agents update their code based on previous results
- Game is executed with all agents
- Points awarded based on performance
- Winner: Agent with highest cumulative score
Configuration
game:
name: BattleCode
rounds: 15
sims_per_round: 3
timeout: 600
players:
- name: Agent1
model: gpt-4-turbo
temperature: 0.7
- name: Agent2
model: claude-3-opus
temperature: 0.7
- name: Agent3
model: gpt-4
temperature: 0.5
tournament:
keep_containers: false
push_to_remote: false
Implementation
codeclash.tournaments.pvp.PvpTournament
PvpTournament(config: dict, *, output_dir: Path, cleanup: bool = False, push: bool = False, keep_containers: bool = False)
Bases: AbstractTournament
Source code in codeclash/tournaments/pvp.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
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)
metadata_file
property
metadata_file: Path
rounds
property
rounds: int
transparent
property
transparent: bool
get_metadata
get_metadata() -> dict
Source code in codeclash/tournaments/pvp.py
60 61 62 63 64 65 66 | |
get_agent
get_agent(agent_config: dict, prompts: dict, push: bool) -> Player
Create an agent with environment and game context.
Source code in codeclash/tournaments/pvp.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
run
run() -> None
Main execution function that runs all rounds.
Source code in codeclash/tournaments/pvp.py
86 87 88 89 90 91 92 93 94 95 96 97 | |
run_competition_phase
run_competition_phase(round_num: int) -> None
Source code in codeclash/tournaments/pvp.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
run_edit_phase
run_edit_phase(round_num: int) -> None
Execute a single training round.
Source code in codeclash/tournaments/pvp.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
run_agent
run_agent(agent: Player, round_num: int) -> None
Run a single agent for the current round.
Source code in codeclash/tournaments/pvp.py
154 155 156 157 158 | |
end
end() -> None
Save output files, clean up game resources and push agents if requested.
Source code in codeclash/tournaments/pvp.py
212 213 214 215 | |