Skip to content

Commit

Permalink
pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dickreuter committed Feb 18, 2024
1 parent 381184f commit 2097436
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
25 changes: 16 additions & 9 deletions agents/agent_consider_equity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions agents/agent_custom_q1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion agents/agent_keras_rl_dqn.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions gym_env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_gym_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2097436

Please sign in to comment.