AbstractTournament
The base class for all tournament types in CodeClash.
Overview
The AbstractTournament class provides:
- Tournament initialization and configuration
- Logging infrastructure
- Metadata collection
- Common utilities for tournament orchestration
Specific tournament types (PvP, SinglePlayer) extend this class.
Tournament Structure
Configuration
All tournaments are configured via YAML files:
game:
name: BattleCode
rounds: 10
sims_per_round: 3
timeout: 300
players:
- name: Agent1
model: gpt-4
- name: Agent2
model: claude-3
Output Directory Structure
logs/
└── {tournament_id}/
├── tournament.log # Main tournament log
├── game.log # Game-specific log
├── everything.log # Combined log
├── metadata.json # Tournament metadata
├── players/
│ └── {player_name}/
│ ├── player.log
│ └── changes_r{N}.json
└── rounds/
└── {round_num}/
└── game logs...
Metadata
Tournament metadata is stored in metadata.json:
{
"name": "pvp",
"tournament_id": "pvp.BattleCode.251104123456",
"created_timestamp": 1730736896,
"config": {
"game": {...},
"players": [...]
}
}
See Also
Class Reference
codeclash.tournaments.tournament.AbstractTournament
AbstractTournament(config: dict, *, name: str, output_dir: Path, **kwargs)
Source code in codeclash/tournaments/tournament.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
config
instance-attribute
config: dict = config
name
instance-attribute
name: str = name
tournament_id
instance-attribute
tournament_id: str = f'{name}.{config['game']['name']}.{strftime('%y%m%d%H%M%S')}'
logger
instance-attribute
logger = get_logger(name, log_path=local_output_dir / 'tournament.log', emoji='🏆')
local_output_dir
property
local_output_dir: Path
get_metadata
get_metadata() -> dict
Source code in codeclash/tournaments/tournament.py
34 35 | |
cleanup_handlers
cleanup_handlers() -> None
Close and remove file handlers to prevent file descriptor leaks.
Source code in codeclash/tournaments/tournament.py
37 38 39 40 41 42 43 44 45 46 | |