Giter Club home page Giter Club logo

poker-sim's Introduction

poker-sim

Python implementation of a Texas Hold'em Monte Carlo Simulator

Overview

This project provides a Monte Carlo simulator for Texas Hold'em hands. It requires as input a number of iterations to run, as well as two 2-card Texas Hold'em hands. You must also specify the community cards. You may specify each card, or allow the program to simulate them.

The program outputs how many times each hand won during the Monte Carlo simulation in absolute terms as well as percentage.

Program Help

Jeremys-Computer> python ./pokersim.py --help usage: pokersim.py [-h] --hand1 HAND1 --hand2 HAND2 [--community COMMUNITY] num_iterations

Run a Monte Carlo simulation of a Texas Hold'em Poker Hand

positional arguments: num_iterations Number of simulations to run. For accurate results, run at least 1000 simulations.

optional arguments: -h, --help show this help message and exit --hand1 HAND1, -h1 HAND1 Hand 1 in format [rank][suit], example AcTd --hand2 HAND2, -h2 HAND2 Hand 2 in format [rank][suit], example Qh5s --community COMMUNITY Community cards in format [rank][suit], example AdTsXxXxXx. You may use Xx for up to five simulated cards

#Sample Run

Sample run using examples from --help:

Jeremys-Computer> python pokersim.py --hand1 AcTd --hand2 Qh5s --community AdTsXxXxXx 1000

Total Hands: 1000 Hand1: 929 Hand2: 66 Ties: 5 Hand1: 92.90% Hand2: 6.60% Ties: 0.50%

Test Suite

The program also includes a test suite (test-pokersim.py) to validate that comparisons are working. It is intended to be run with nosetests:

Jeremys-Computer> nosetests -v

test_best_five (test-pokersim.TestPokerSim) ... ok test_check_flush (test-pokersim.TestPokerSim) ... ok test_check_straight (test-pokersim.TestPokerSim) ... ok test_check_straightflush (test-pokersim.TestPokerSim) ... ok test_compare_hands (test-pokersim.TestPokerSim) ... ok test_fourofakind (test-pokersim.TestPokerSim) ... ok test_fullhouse (test-pokersim.TestPokerSim) ... ok test_hand_copy (test-pokersim.TestPokerSim) ... ok test_hand_to_numeric (test-pokersim.TestPokerSim) ... ok test_highest_card (test-pokersim.TestPokerSim) ... ok test_highest_card_straight (test-pokersim.TestPokerSim) ... ok test_onepair (test-pokersim.TestPokerSim) ... ok test_readable_hand (test-pokersim.TestPokerSim) ... ok test_threeofakind (test-pokersim.TestPokerSim) ... ok test_twopair (test-pokersim.TestPokerSim) ... ok


Ran 15 tests in 0.008s

OK

poker-sim's People

Contributors

jfilliben avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.