From 2097436800533744d08cf4caa71b7a0a3b23d955 Mon Sep 17 00:00:00 2001 From: Nicolas Dickreuter Date: Sun, 18 Feb 2024 02:11:42 +0100 Subject: [PATCH] pylint fixes --- agents/agent_consider_equity.py | 25 ++++++++++++++++--------- agents/agent_custom_q1.py | 1 + agents/agent_keras_rl_dqn.py | 2 +- gym_env/env.py | 1 + tests/test_gym_env.py | 3 +-- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/agents/agent_consider_equity.py b/agents/agent_consider_equity.py index 22ab03b..4c02a7a 100644 --- a/agents/agent_consider_equity.py +++ b/agents/agent_consider_equity.py @@ -2,13 +2,11 @@ from gym_env.env import Action -autoplay = True # play automatically if played against keras-rl - class Player: """Mandatory class with the player methods""" - def __init__(self, name='Random', min_call_equity=None, min_bet_equity=None): + def __init__(self, name="Random", min_call_equity=None, min_bet_equity=None): """Initiaization of an agent""" self.equity_alive = 0 self.name = name @@ -21,21 +19,30 @@ def __init__(self, name='Random', min_call_equity=None, min_bet_equity=None): def action(self, action_space, observation, info): # pylint: disable=no-self-use """Mandatory method that calculates the move based on the observation array and the action space.""" _ = observation - equity_alive = info['player_data']['equity_to_river_alive'] + equity_alive = info["player_data"]["equity_to_river_alive"] - incremen1 = .1 - increment2 = .2 + incremen1 = 0.1 + increment2 = 0.2 - if equity_alive > self.min_bet_equity + increment2 and Action.ALL_IN in action_space: + if ( + equity_alive > self.min_bet_equity + increment2 + and Action.ALL_IN in action_space + ): action = Action.ALL_IN - elif equity_alive > self.min_bet_equity + incremen1 and Action.RAISE_2POT in action_space: + elif ( + equity_alive > self.min_bet_equity + incremen1 + and Action.RAISE_2POT in action_space + ): action = Action.RAISE_2POT elif equity_alive > self.min_bet_equity and Action.RAISE_POT in action_space: action = Action.RAISE_POT - elif equity_alive > self.min_bet_equity - incremen1 and Action.RAISE_HALF_POT in action_space: + elif ( + equity_alive > self.min_bet_equity - incremen1 + and Action.RAISE_HALF_POT in action_space + ): action = Action.RAISE_HALF_POT elif equity_alive > self.min_call_equity and Action.CALL in action_space: diff --git a/agents/agent_custom_q1.py b/agents/agent_custom_q1.py index 695861b..cb297e4 100644 --- a/agents/agent_custom_q1.py +++ b/agents/agent_custom_q1.py @@ -6,6 +6,7 @@ from agents.agent_keras_rl_dqn import TrumpPolicy, memory_limit, window_length from gym_env import env +# pylint: disable=import-error class Player: """Mandatory class with the player methods""" diff --git a/agents/agent_keras_rl_dqn.py b/agents/agent_keras_rl_dqn.py index 20c406a..b868adf 100644 --- a/agents/agent_keras_rl_dqn.py +++ b/agents/agent_keras_rl_dqn.py @@ -1,5 +1,5 @@ """Player based on a trained neural network""" -# pylint: disable=wrong-import-order,invalid-name +# pylint: disable=wrong-import-order,invalid-name,import-error,missing-function-docstring import logging import time diff --git a/gym_env/env.py b/gym_env/env.py index 2ffcc93..ed6a673 100644 --- a/gym_env/env.py +++ b/gym_env/env.py @@ -914,6 +914,7 @@ def __init__(self, stack_size, name): self.temp_stack = [] self.name = name self.agent_obj = None + self.cards = None self.num_raises_in_street = {Stage.PREFLOP: 0, Stage.FLOP: 0, Stage.TURN: 0, diff --git a/tests/test_gym_env.py b/tests/test_gym_env.py index e6ad9a8..cf20f68 100644 --- a/tests/test_gym_env.py +++ b/tests/test_gym_env.py @@ -122,8 +122,7 @@ def test_raise_to_3_times_big_blind_is_possible_with_enough_remaining_stack(): assert env.players[0].stack == 0 -@pytest.mark.skip("Test-scenario is not like title of the test and player_cycle.alive has by several executions a " - "changed behaviour") + def test_heads_up_after_flop(): """All in at pre-flop leads to heads up after flop. For more info about skipping of this test see https://github.com/dickreuter/neuron_poker/issues/39.