Skip to content
Mark Percival edited this page Oct 30, 2012 · 21 revisions

Machine Poker Guide

Building your bot

Bots are written in CommonJS, and simple need to export a 'play' function

Example: At it's simplest, a bot should return a bet. Bets are essentially what's getting added to the pot. You can think about it as throwing new chips into the pot.

// I just call everything!
exports.play = function(game) {
  if(game.state !== "complete") {
    return game.betting.call;
  }
};

Game object

You should expect to be passed a game object which contains all the relevant information you need to make a decision, such as the game's state('flop','river', etc.), players and their actions, your own information (including your cards), and your betting options.

Here's an example of a game object after the flop.

{ community: [ 'Kh', '7c', '2c' ],
  state: 'flop',
  hand: 1,
  betting: { call: 10, raise: 20, canRaise: true },
  me: 
   { name: 'Me',
     blind: 5,
     ante: 0,
     wagered: 10,
     state: 'active',
     chips: 990,
     actions: { 'pre-flop': [ { type: 'call', bet: 5 } ] },
     cards: [ '6s', 'Qh' ],
     position: 0,
     brain: {} },
  players: 
   [ { name: 'Me',
       blind: 5,
       ante: 0,
       wagered: 10,
       state: 'active',
       chips: 990,
       actions: { 'pre-flop': [ { type: 'call', bet: 5 } ] } },
     { name: 'CallBot #1',
       blind: 10,
       ante: 0,
       wagered: 10,
       state: 'active',
       chips: 990,
       actions: { 'pre-flop': [ { type: 'check' } ] } },
     { name: 'RandBot #1',
       blind: 0,
       ante: 0,
       wagered: 10,
       state: 'active',
       chips: 990,
       actions: { 'pre-flop': [ { type: 'call', bet: 10 } ] } } ] }

Betting

Your play function should simply return a integer of the amount to wish to bet.

This bet is in ADDITION to the amount you've already wagered. This can be thought of as tossing more money into the pot.

For example, lets say you've wagered $10 so far, and are presented with the following betting state.

{ community: [ 'Kh', '7c', '2c' ],
  state: 'flop',
  hand: 1,
  betting: { call: 10, raise: 20, canRaise: true },
  me:
   { name: 'Me',
     blind: 5,
     ante: 0,
     wagered: 10,
     state: 'active',
     chips: 990,
     actions: { 'pre-flop': [ { type: 'call', bet: 5 } ] },
     cards: [ '6s', 'Qh' ],
     position: 0,
  // Concatinated for brevity
  • A bet of 0 will result in a fold, because you need to bet 10 in order to stay in the game.

  • A bet of 10 will result in a call.

  • You can also bet 20 or more in order to raise. If you've already raised and there have been no subsequent raises, you won't be able to raise again and the canRaise flag will be set to false

What happens if I return back an invalid amount?

Basic format

Your brain

Game data

During gameplay

Settled game data

Clone this wiki locally