Skip to main content

A poker environment for reinforcement learning

Project description

Overview

This is a poker environment for reinforcement learning.

Installation

run

python build.py

Instructions

To instantiate the environment, pass in the config.

the config consists of the following parameters:

  • number of players (2-6), default 2
  • bet limit (fixed limit, no limit, pot limit), default pot limit
  • bet sizes allowed (array of floats), default (1, 0.9, 0.75, 0.67, 0.5, 0.33, 0.25, 0.1)
  • Game type [Holdem, OmahaHI], default OmahaHI

Example usage

This is the recommended way to use the environment.

from pokerrl import Config, Game

config = Config(
    num_players=2,
    bet_limit=BetLimits.POT_LIMIT,
    bet_sizes=[1, 0.5],
    game_type=GameTypes.OMAHA_HI,
)
game = Game(config)
player_state,done,winnings,action_mask = game.reset()
while not done:
  action = model(player_state)
  player_state,done,winnings,action_mask = game.step(action)

Play a game (both sides)

from pokerrl import play_game
play_game()

Example usage (low level)

from pokerrl import Config, init_state, step_state, GameTypes, BetLimits, player_view, Positions, get_current_player

config = Config(
    num_players=2,
    bet_limit=BetLimits.POT_LIMIT,
    bet_sizes=[1, 0.5],
    game_type=GameTypes.OMAHA_HI,
)
global_state,done,winnings,action_mask = init_state(config)
while not done:
  player_idx = get_current_player(global_state)
  player_state = player_view(global_state, player_idx)
  action = model(player_state)
  global_state,done,winnings,action_mask = step_state(global_state, action, config)

Player view (low level)

from pokerrl import Config, init_state, step_state, GameTypes, BetLimits, player_view, Positions, get_current_player

config = Config()
global_state,done,winnings,action_mask = init_state(config)
while not done:
  player_idx = get_current_player(global_state)
  human_readable_view(global_state,player_idx, config)
  action = get_action(action_mask,global_state,config)
  global_state,done,winnings,action_mask = step_state(global_state, action, config)

State

The state is an array. To get a player's view of the state, pass the state into the view with the appropriate player index.

Design decisions

  • Record the total amount raised. If you record the actual amount raised this means its more difficult to tell what the raise size is when facing multiple raises. But easier to tell what the raise size is when facing a single raise. Also complicates the process of determining how much a player has to call, as the raise size is in relation to the previous bet, which in multiplayer games, is not necessarily the current player.

  • Global state player numbers are identical to their position.

  • SB and BB posts are the first two states.

  • A raise is the total amount. Subtract player street total

  • A call vs a raise is the difference = villain bet - player street total

  • A call vs a bet is the full amount = villain bet - player street total

  • A bet is the full amount

  • A fold is 0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pokerrl_env-0.1.4.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pokerrl_env-0.1.4-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file pokerrl_env-0.1.4.tar.gz.

File metadata

  • Download URL: pokerrl_env-0.1.4.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pokerrl_env-0.1.4.tar.gz
Algorithm Hash digest
SHA256 71ec68ed18c1b5d0911a6d683c3d3f8e51f130cc1cc2df2a8636c956a0072878
MD5 f771a100e19bd0721e8e3d09f970ad7f
BLAKE2b-256 f3e6c9341175c2c45a05454b8ad1c9c2830f2ed1c877172ca4517ffd3558bc39

See more details on using hashes here.

File details

Details for the file pokerrl_env-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pokerrl_env-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pokerrl_env-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 242e037eb97afb38c8c5c26c8e9b9520c1b61facf19e6ef1682688903922bf8b
MD5 35de526604510bbdea37b6dbef4b37df
BLAKE2b-256 c8e6bfcf88c28565b5f05467b579d6cb206744d494cfa32bd5534f0b25e0f180

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page