checkpoint

This commit is contained in:
Moritz Gmeiner 2026-08-07 22:06:27 +02:00
commit d0deefd8cf
35 changed files with 2543 additions and 0 deletions

30
tests/test_opponents.py Normal file
View file

@ -0,0 +1,30 @@
import pytest
from generals.agents import ExpanderAgent, HunterAgent, RandomAgent
from general_bots_training.opponents import SelfPlayOpponent, make_opponent
@pytest.mark.parametrize(
("name", "expected_type"),
[
("random", RandomAgent),
("expander", ExpanderAgent),
("hunter", HunterAgent),
],
)
def test_make_opponent(name, expected_type):
assert isinstance(make_opponent(name), expected_type)
def test_make_opponent_is_case_insensitive():
assert isinstance(make_opponent("HUNTER"), HunterAgent)
def test_make_opponent_supports_self_play_aliases():
assert isinstance(make_opponent("self_play"), SelfPlayOpponent)
assert isinstance(make_opponent("self-play"), SelfPlayOpponent)
def test_make_opponent_rejects_unknown_name():
with pytest.raises(ValueError, match="unknown opponent"):
make_opponent("turtle")