Skip to main content

A poker environment for reinforcement learning

Project description

Poker environment for reinforcement learning

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 us.

  • 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.3.tar.gz (19.1 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.3-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pokerrl_env-0.1.3.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.12 Darwin/22.2.0

File hashes

Hashes for pokerrl_env-0.1.3.tar.gz
Algorithm Hash digest
SHA256 55bb8b1bdc6bf1fbef8af73dc485a5c8536818ecfc4892a645591bc1d528a905
MD5 bdd0fa113f47f7ac52c6384b2652df9f
BLAKE2b-256 1d06152cb430db731fbf211011664e291163baf56205038a68486660368ddfd7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pokerrl_env-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.12 Darwin/22.2.0

File hashes

Hashes for pokerrl_env-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 37992e1fff99c1496b85d2251409fc0c55de6d98de8a8ab09b82d5a39918cd63
MD5 bb3fcd291c290bdc275bed04b3d7b3b2
BLAKE2b-256 c50a2c64c03ce720d2a57c4c0d425957806b28eb59667895ef884a14595aa1e9

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