Skip to content

DummyAgent

Simple test agent for development and debugging.

Overview

DummyAgent is a minimal agent implementation used for testing.

Implementation

codeclash.agents.dummy_agent.Dummy

Dummy(config: dict, environment: DockerEnvironment, game_context: GameContext, push: bool = False)

Bases: Player

A dummy player that does nothing. Mainly for testing purposes.

Source code in codeclash/agents/player.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def __init__(
    self,
    config: dict,
    environment: DockerEnvironment,
    game_context: GameContext,
    push: bool = False,
) -> None:
    self.config = config
    self.name = config["name"]
    self._player_unique_id = str(uuid.uuid4())
    """Unique ID that doesn't clash even across multiple games. Used for git tags."""
    self.environment = environment
    self.game_context = game_context
    self.push = push
    self.logger = get_logger(
        self.name,
        log_path=self.game_context.log_local / "players" / self.name / "player.log",
        emoji="👤",
    )
    self._metadata = {
        "name": self.name,
        "player_unique_id": self._player_unique_id,
        "created_timestamp": int(time.time()),
        "config": self.config,
        "initial_commit_hash": self._get_commit_hash(),
        "branch_name": self._branch_name,
        "round_tags": {},  # mapping round -> tag
        "agent_stats": {},  # mapping round -> agent stats
    }

    if branch := config.get("branch_init"):
        self.logger.info(f"Checking out branch {branch}")
        assert_zero_exit_code(self.environment.execute(f"git checkout {branch}"), logger=self.logger)

    if self.push:
        self.logger.info("Will push agent gameplay as branch to remote repository after each round")
        token = os.getenv("GITHUB_TOKEN")
        if not token:
            raise ValueError("GITHUB_TOKEN environment variable is required")
        for cmd in [
            "git remote remove origin",
            f"git remote add origin https://x-access-token:{token}@github.com/{GH_ORG}/{self.game_context.name}.git",
        ]:
            assert_zero_exit_code(self.environment.execute(cmd), logger=self.logger)

run

run()
Source code in codeclash/agents/dummy_agent.py
7
8
def run(self):
    pass

Usage

Useful for: - Testing game implementations - Debugging tournament infrastructure - Baseline performance comparison

Configuration

players:
  - name: DummyPlayer
    type: dummy