-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
65 lines (55 loc) · 2.6 KB
/
Copy pathmain.py
File metadata and controls
65 lines (55 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
64
65
"""CLI entry point: play a Codenames game.
Use --red and --blue to pick agent types for each team. The agent type applies
to both the codemaster and the guesser on that team.
"""
import argparse
from codenames import Game
from codenames.players import HumanCodemaster, HumanGuesser, RandomCodemaster, RandomGuesser
from codenames.players.cheat import CheatCodemaster, CheatGuesser
from codenames.players.embedding import (
EmbeddingCodemaster, EmbeddingGuesser,
Margin2EmbeddingCodemaster, MarginEmbeddingCodemaster, PrefixEmbeddingCodemaster,
)
from codenames.players.llm import ClaudeCodemaster, ClaudeGuesser
PLAYERS = {
"human": (HumanCodemaster, HumanGuesser),
"random": (RandomCodemaster, RandomGuesser),
"claude": (ClaudeCodemaster, ClaudeGuesser),
"embedding": (EmbeddingCodemaster, EmbeddingGuesser),
"embedding-prefix": (PrefixEmbeddingCodemaster, EmbeddingGuesser),
"embedding-margin": (MarginEmbeddingCodemaster, EmbeddingGuesser),
"embedding-margin2": (Margin2EmbeddingCodemaster, EmbeddingGuesser),
"cheat": (CheatCodemaster, CheatGuesser),
}
def main():
parser = argparse.ArgumentParser(description="Play a Codenames game.")
parser.add_argument("--red", choices=PLAYERS, default="human",
help="Agent type for red team (codemaster + guesser).")
parser.add_argument("--blue", choices=PLAYERS, default="human",
help="Agent type for blue team (codemaster + guesser).")
parser.add_argument("--seed", type=int, default=None,
help="Random seed for the board (default: time-based).")
parser.add_argument("--single-team", action="store_true",
help="Single-team mode (Red plays alone, no turn passing on wrong guess).")
parser.add_argument("--max-turns", type=int, default=30,
help="Turn limit (default: 30).")
parser.add_argument("--log-dir", nargs="?", const="logs", default=None,
help="Enable game logging. Optional directory (default: logs/).")
parser.add_argument("--no-print", action="store_true",
help="Disable colored board printing during play.")
args = parser.parse_args()
red_cm, red_gr = PLAYERS[args.red]
if args.single_team:
blue_cm, blue_gr = None, None
else:
blue_cm, blue_gr = PLAYERS[args.blue]
Game(
red_cm, red_gr, blue_cm, blue_gr,
seed=args.seed,
single_team=args.single_team,
max_turns=args.max_turns,
log_dir=args.log_dir,
do_print=not args.no_print,
).run()
if __name__ == "__main__":
main()