diff --git a/Makefile b/Makefile index 02a911f..ea00518 100644 --- a/Makefile +++ b/Makefile @@ -127,7 +127,7 @@ check-mypy: mypy . check-pylint: - pylint solvers/ --fail-under=9.68 + pylint solvers/ --fail-under=10 lint: format pre-commit run --all-files diff --git a/poetry.lock b/poetry.lock index 85368ce..660eaa1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -658,13 +658,13 @@ click = ">=8.0,<9.0" [[package]] name = "codenames" -version = "5.0.4" +version = "5.1.2" description = "Codenames board game logic implementation in python." optional = false python-versions = "<4.0,>=3.12" files = [ - {file = "codenames-5.0.4-py3-none-any.whl", hash = "sha256:f10a1611c84f728e9bce44443c8a5c36ee74dc5a64004dafef810e12a09fbf40"}, - {file = "codenames-5.0.4.tar.gz", hash = "sha256:ab7b1cf2e748a464ca01bbe88fe6a8c466efe385c37eda99cb593fc44e904ba1"}, + {file = "codenames-5.1.2-py3-none-any.whl", hash = "sha256:56587745a53894f3828ff4adda31fd0b9fa0c511fd0ed7d30d1892cd20b10465"}, + {file = "codenames-5.1.2.tar.gz", hash = "sha256:c7b3d546ce97e99015c174bc0768c71fcfe2fe211cb216439b19d30cfe4c9228"}, ] [package.dependencies] @@ -5167,4 +5167,4 @@ gpt = ["openai"] [metadata] lock-version = "2.0" python-versions = "^3.12,<3.13" -content-hash = "a217f447965497d5605a520d9e8511553dd571750bcf46ca79a762449bf47f1f" +content-hash = "08091c6194eb48e9ce7abf6df70e17bf6a7b2b1459ab5e95b450ab4ee72d990f" diff --git a/pyproject.toml b/pyproject.toml index 549e77e..c9b8753 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ all = ["openai"] # Core python = "^3.12,<3.13" the-spymaster-util = { version = "~3.2", extras = ["logging"] } -codenames = ">=5.0.4,<5.1" +codenames = ">=5.1.2" pydantic = ">=2.4" # Numbers numpy = "^1.21" @@ -122,8 +122,8 @@ disable = [ ] extension-pkg-allow-list = ["pydantic"] ignore = [ - "sna_hinter.py", + "solvers/sna", + "solvers/olympic", "algebra.py", - "olympic_hinter.py", "board_heuristics.py", ] diff --git a/solvers/gpt/gpt_spymaster.py b/solvers/gpt/gpt_spymaster.py index c66024a..dd5d27f 100644 --- a/solvers/gpt/gpt_spymaster.py +++ b/solvers/gpt/gpt_spymaster.py @@ -7,7 +7,7 @@ from codenames.generic.move import Clue, GivenClue from codenames.generic.player import Spymaster, Team from codenames.generic.state import SpymasterState -from codenames.resources.english import ENGLISH_WORDS +from codenames.utils.vocabulary.english import ENGLISH_WORDS from solvers.gpt.gpt_player import ( HINTER_TURN_COMMAND, diff --git a/solvers/naive/naive_spymaster.py b/solvers/naive/naive_spymaster.py index 4c1f78c..11e6500 100644 --- a/solvers/naive/naive_spymaster.py +++ b/solvers/naive/naive_spymaster.py @@ -4,7 +4,9 @@ import numpy as np from codenames.classic.color import ClassicColor -from codenames.classic.state import ClassicState +from codenames.classic.state import ClassicPlayerState +from codenames.duet.card import DuetColor +from codenames.duet.state import DuetPlayerState from codenames.generic.board import Board from codenames.generic.move import Clue from codenames.generic.player import Spymaster, Team @@ -116,11 +118,18 @@ def give_clue( def _get_proposal_colors(state: PlayerState) -> ProposalColors: - if isinstance(state, ClassicState): + if isinstance(state, ClassicPlayerState): return ProposalColors( team=state.current_team.as_card_color, opponent=state.current_team.opponent.as_card_color, neutral=ClassicColor.NEUTRAL, assassin=ClassicColor.ASSASSIN, ) + if isinstance(state, DuetPlayerState): + return ProposalColors( + team=state.current_team.as_card_color, + opponent=None, + neutral=DuetColor.NEUTRAL, + assassin=DuetColor.ASSASSIN, + ) raise NotImplementedError(f"Unsupported state type: {type(state)}") diff --git a/tests/resources/__init__.py b/tests/resources/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/resources/resource_manager.py b/tests/resources/resource_manager.py new file mode 100644 index 0000000..02815cd --- /dev/null +++ b/tests/resources/resource_manager.py @@ -0,0 +1,7 @@ +import os + +RESOURCE_DIR = os.path.join(os.path.dirname(__file__)) + + +def get_resource_path(resource_name: str) -> str: + return os.path.join(RESOURCE_DIR, resource_name) diff --git a/tests/small_model.csv b/tests/resources/small_model.csv similarity index 100% rename from tests/small_model.csv rename to tests/resources/small_model.csv diff --git a/tests/words.py b/tests/resources/words.py similarity index 100% rename from tests/words.py rename to tests/resources/words.py diff --git a/tests/test_naive_flow_classical.py b/tests/test_naive_flow_classical.py index f47e605..785129c 100644 --- a/tests/test_naive_flow_classical.py +++ b/tests/test_naive_flow_classical.py @@ -9,9 +9,10 @@ from solvers.naive.naive_operative import NaiveOperative from solvers.naive.naive_spymaster import NaiveSpymaster -from tests.words import ALL_WORDS +from tests.resources.resource_manager import get_resource_path +from tests.resources.words import ALL_WORDS -VECTORS_FILE_NAME = "tests/small_model.csv" +VECTORS_FILE_NAME = get_resource_path("small_model.csv") def mock_load_word2vec_format(*args, **kwargs): diff --git a/utils/logging.py b/utils/logging.py index 41b7b46..7f95713 100644 --- a/utils/logging.py +++ b/utils/logging.py @@ -7,13 +7,13 @@ def configure_logging( formatter: Optional[str] = None, level: Optional[str] = None, mute_solvers: bool = False, mute_online: bool = True ): - handlers = { - "file": { - "class": "logging.FileHandler", - "filename": "run.log", - "formatter": "debug", - }, - } + # handlers = { + # "file": { + # "class": "logging.FileHandler", + # "filename": "run.log", + # "formatter": "debug", + # }, + # } loggers = { "selenium": {"level": "INFO"}, "urllib3": {"level": "INFO"}, @@ -24,14 +24,14 @@ def configure_logging( dict_config = get_dict_config( std_formatter=formatter, root_log_level=level, - extra_handlers=handlers, + # extra_handlers=handlers, extra_loggers=loggers, ) - dict_config["root"]["handlers"].append("file") + # dict_config["root"]["handlers"].append("file") - if mute_solvers: - dict_config["loggers"]["solvers"] = {"handlers": ["file"], "propagate": False} # type: ignore - if mute_online: - dict_config["loggers"]["codenames.online"] = {"handlers": ["file"], "propagate": False} # type: ignore + # if mute_solvers: + # dict_config["loggers"]["solvers"] = {"handlers": ["file"], "propagate": False} # type: ignore + # if mute_online: + # dict_config["loggers"]["codenames.online"] = {"handlers": ["file"], "propagate": False} # type: ignore dictConfig(dict_config) print("Logging configured.")