From e54add409d6c7099d5176ae4c0c4b4d8e6aaa860 Mon Sep 17 00:00:00 2001 From: Nicolas Dickreuter Date: Fri, 16 Feb 2024 12:20:10 +0100 Subject: [PATCH] ensure agents are added before reset --- gym_env/env.py | 5 +++++ poetry.lock | 34 +++++++++++++++++++++++++++++++++- pyproject.toml | 1 + readme.rst | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/gym_env/env.py b/gym_env/env.py index 32778a7..fc65ead 100644 --- a/gym_env/env.py +++ b/gym_env/env.py @@ -168,6 +168,11 @@ def reset(self): self.funds_history = pd.DataFrame() self.first_action_for_hand = [True] * len(self.players) + if not self.players: + log.warning("No agents added. Add agents before resetting the environment.") + return + + for player in self.players: player.stack = self.initial_stacks diff --git a/poetry.lock b/poetry.lock index 967ae52..4a3f254 100644 --- a/poetry.lock +++ b/poetry.lock @@ -294,6 +294,23 @@ files = [ [package.extras] colors = ["colorama (>=0.4.6)"] +[[package]] +name = "jinja2" +version = "3.1.3" +description = "A very fast and expressive template engine." +optional = false +python-versions = ">=3.7" +files = [ + {file = "Jinja2-3.1.3-py3-none-any.whl", hash = "sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa"}, + {file = "Jinja2-3.1.3.tar.gz", hash = "sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"}, +] + +[package.dependencies] +MarkupSafe = ">=2.0" + +[package.extras] +i18n = ["Babel (>=2.7)"] + [[package]] name = "kiwisolver" version = "1.4.5" @@ -554,6 +571,21 @@ files = [ {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, ] +[[package]] +name = "mpld3" +version = "0.5.10" +description = "D3 Viewer for Matplotlib" +optional = false +python-versions = "*" +files = [ + {file = "mpld3-0.5.10-py3-none-any.whl", hash = "sha256:80877acce87ea447380fad7374668737505c8c0684aab05238e7c5dc1fab38c1"}, + {file = "mpld3-0.5.10.tar.gz", hash = "sha256:a478eb404fa5212505c59133cf272cd9a94105872e605597720e7f84de38fbc7"}, +] + +[package.dependencies] +jinja2 = "*" +matplotlib = "*" + [[package]] name = "numpy" version = "1.26.4" @@ -971,4 +1003,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "47b03aba1f696b16d7eaf758dea13e24e7eafffb578069efce0d4dc3fc8d0f1c" +content-hash = "8464ea9da53d881d349e026efbefcbd082bbc68b41fcb4cd5693659f3620bfc4" diff --git a/pyproject.toml b/pyproject.toml index 8c06f83..289d32b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ cppimport = "^22.8.2" docopt = "^0.6.2" pydocstyle = "^6.3.0" matplotlib = "^3.8.2" +mpld3 = "^0.5.10" [build-system] diff --git a/readme.rst b/readme.rst index e2d59ce..9ba84d4 100644 --- a/readme.rst +++ b/readme.rst @@ -14,7 +14,7 @@ Run: - Install Poetry with ``curl -sSL https://install.python-poetry.org | python3 -`` - Create a virtual environment with ``poetry env use python3.11`` - Activate it with ``poetry shell`` -- Install all required packages with ``poetry install`` +- Install all required packages with ``poetry install --no-root`` - Run 6 random players playing against each other: ``poetry run python main.py selfplay random --render`` or - To manually control the players:``poetry run python main.py selfplay keypress --render``