Giter VIP home page Giter VIP logo

jspoker's Introduction

JS Poker

JS Poker

A No-limit Texas Hold'em poker tournament for Javascript bots played via pull requests with Travis CI as the dealer.

Bounty challenge complete

Current Winning Players

  1. status3Bot $152306
  2. ThoseAreMyFish $105849
  3. edi9999 $67519
  4. SneakyCharlie $17395
  5. FlopASetBot $3520
  6. whistle_tips $2081
  7. blaBot $1330

Introduction

JsPoker is an automated poker competition, where your opponents are bots written in Javascript. At the moment they are each quite unintelligent/unimaginative. The challenge is to write a competitor in JS that can handily beat them all over the course of 50 tournaments, each with a maximum of 500 hands.

You win if your bot beats the challenged return on it's money, and we consider a bounty claimed when your bot is submitted via a pull request and the Travis-CI tests pass. (Tests will run the tournament simulation and pass or fail based on performance)

Example:

Each bot starts with $1000 for every tournament, regardless of past performance. It must play 50 tournaments against the other bots. Therefore the bot is putting up $50k in total in the tournaments and needs to see a return of $100k if the challenge is 2x. This may seem hard, but keep in mind that over the course of 50 tournaments, the other bots are putting $300k into the pot, you only need to take 1/3 of this.

If you win, your bot will be added to the table to play future bots.

Why

Like many people, I like to play poker and lose money. The obvious next step was to automate this.

How to play

  1. Clone this repo and run 'npm install'
  2. Modify the existing challenger bot
  3. Tune it to double your money over the course of 25,000 hands (50 Tournaments of 500 hands each)
  4. Test it with npm test until your confident it has a good chance of winning.
  5. Submit a pull request. If the Travis tests pass, you win the bounty.
  6. First pull request that passes wins the current round.
  7. Winning bot is added to the table. Contest repeats.

Rules

  1. The game is No-limit Texas Hold'em ($10-20), with each player starting with $1000
  2. Only one file may be modified in the pull request, 'players/challengerBot.js' (Pull requests to fix other issues are gladly accepted however)
  3. You cannot load any modules. This includes Node.js core modules (fs, http, etc.)
  4. Source code may not be obsfuscated/minified. Everyone should be able to learn from your winning bot.
  5. Bots must win through legitimate poker play. Hacking is fine, but the bounty will only be paid to legitimate winners. Think of it this way, if your bot was in a casino, would it get kicked out or arrested?
  6. Only 2 attempts per user, per 24 hour period. You can't just keep updating the pull request and having Travis repeatedly rerun the tests to try and win by luck. I'll consider this is a soft limit, but in general, don't be an ass. TravisCI is a fantastic tool and I don't want to abuse their time or resources.

Installation

# Requires NodeJs >= 0.10.0
git clone https://github.com/mdp/JsPoker.git
cd JsPoker
npm install
npm test
# Now go and turn your bot into a champion!

Building a better poker bot

You can test out your bot with a small 100 hand game using play.js

node play.js

The output will include each bots betting actions and cards held in order to make tuning and debugging easier.

Game data and bot actions

Bots are handed a game data object with the current state of the game and simply have to return a wager as an integer.

Game data

Here's an example game date payload: GameData.json

Game object consists of 6 properties:

  • self Your bots current standing/cards
  • hand The current number hand being played
  • state The betting state of the game. Ex. 'river'
  • betting Betting options available - These are incremental wager options
  • players Array of each player, their actions for any round, and wager/stack
  • community Community cards

Bot Actions

In Texas Hold'em, you're only real options are to stay in the game, or fold. With that in mind bots only need to return an integer representing the additional amount they wish to add to the pot.

The game objects betting property shows the betting options available to the player/bot. call represents the additional amount needed to stay in the game, while raise represents the minimum amount a player can bet if they wish to raise.

  • Wagers of less than the amount required to call are considered a 'fold'
  • Wagers of '0', when the call amount is '0', are considered a check.
  • Wagers greater than the call, but less than the minimum raise will result in a call
  • A negative wager will force a fold.
  • Failure to return an integer will assume a wager of '0', which may in turn result in a fold

Example players

Here's an extremely simple bot that only raises each betting round:

// I only raise!
module.exports = function () {
  var info = {
    name: "RaiseBot"
  };
  function play(game) {
    if (game.state !== "complete") {
      return game.betting.raise;
    }
  }

  return { play: play, info: info }
}

Take a look at the code for the current set of players. Here are a couple decent examples:

Goals

MachinePoker (The library behind JsPoker) will eventually be a platform that allows people to play their bots against each other in real time for real money (In jurisdictions that allow it)

  • Anyone with a small amount of programming experience should be able to play.
  • It should be easy to run a tournament for a group of competitors safely (Skilled play vs Clever hacks)
  • Competitors should be able to lose (or win) real money.
  • Hardware constraints (ex. Bots are each hosted on their own Raspberry Pi)

Contribute

  • Found a bug? By all means feel free to report it or send me a pull request.
  • The next step is to build a tournament system for handling a real-time tournament with separate players, each on their own host.
  • It would be great to give people a way to watch or monitor game play.

Resources

Requirements

  • Node.js >= 0.10
  • an 80386sx microprocessor or better with at least 8 MB of RAM
  • OSx, Ubuntu, BSD, or some other POSIX compatible file system. (I don't have a windows machine to test with. Happy to take PR's to fix this)

jspoker's People

Contributors

daftmonk avatar johndoe1995 avatar jonnyburger avatar lorenzo-stoakes avatar mdp avatar owensbla avatar robertcorey avatar tollus avatar whistle-tips avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jspoker's Issues

Windows npm test command

I forgot to mention originally that I had to modify the package.json to have the mocha test work for me on Windows. The change is below, but I didn't know what this would do to other O/S.

{
//...
  "scripts": {
    "test": "node ./node_modules/mocha/bin/mocha"
  }
//...
}

Just added "node" in front of the mocha command.

Bug in status3bot

Hi

nice work first of all. I was checking the bots code and see an issue in status3bot, in preflop strategy this is the code:

var action_so_far = Array('raised', 'folded', 'limpers');
        var hand_type = Array('hn', 'pr', 'cn', 'su', 'sc');

        for(i = 0;i < action_so_far.length;i++) {
            for(j = 0;j < hand_type.length;j++) {
                var match = false;

                switch(j) {
                    case 'hn':
                        match = true;
                        break;

                    case 'pr':
                        match = hand.pair;
                        break;

                    case 'cn':
                        match = (hand.connected == 1);
                        break;

                    case 'su':
                        match = hand.suited;
                        break;

                    case 'sc':
                        match = (hand.suited && (hand.connected == 1));
                        break;

in evaluate_preflop method in this switch statement you are checking value of j. but it cannot be ever 'hn'/'pr'.... hence it never raises or do anything except calling the hand. i am not sure what you wanted to write down there.

Can you resolve this?

Blinds are not increasing during the tournament?

Not sure how active you are in this repo (a few PR's from two years ago are still open) but I came across it last repo week and now I'm writing my own bot for the tournament.

Either I am missing something but could it be that the blinds remain the same (5/10) during the tournament?

MonteCarlo evBot

I have discovered a truly marvelous solution for this, which this margin is too narrow to contain! :D

Seriously tho, I don't think I can/should get it running on Travis as it eats a lot of resources, but my winning algorithm was incredibly simple:

wager = pot * odds * aggression;

// where:
// pot = sum(current wagers),
// odds = odds of winning (0.0-1.0),
// aggression = tweakable constant (1.5 seems stable)

So basically pot*odds = EV, or what I expect to win, surprisingly betting more than that was A LOT more effective (aggression 1.1-4) than betting under (0.5-0.9).

The hard part was calculating the odds. Got the 2+2 evaluator running from:
https://web.archive.org/web/20140625212722/http://codingthewheel.com/archives/poker-hand-evaluator-roundup/#2p2
https://github.com/christophschmalhofer/poker/tree/master/XPokerEval/XPokerEval.TwoPlusTwo

Then I did a bunch of Monte-Carlo simulations - basically dealt every player and the community random cards (except the cards I know ofc) over and over again and counted the win/loose ratio (1k iterations per move seem to be enough). And ta-dah!

Player Standings

1. evBot $161249
2. Wittgenstein $72170
3. edi9999 $39935
4. status3Bot $35575
5. SneakyCharlie $27337
6. FlopASetBot $10068
7. whistle_tips $3666

But, yeah, multiple problems to submit it

  • the lookup table for the evaluator is ~130 megs, Travis could probably still pull this tho
  • it eats a lot of CPU as it needs ~1k simulations each move
  • the Monte-Carlo simulator is currently written in C++ and acts as a TCP server to communicate with the bot, would require some work to compile/run on Travis in the background... also it has windows sockets.
  • it obviously breaks the "no-modules" and "one file edit per pull" rules atm

Just wanted to share my solution. Someone might be able to do a similar/simpler version in just JS. Feel free to close this if needed.

Poker Engine

Hi there,

Can this code be used as poker engine for real human multiplayer game ? I know this is made for bots, but I wonder is poker logic is there ?

My idea is to add GUI and let real people play.

Stefan

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.