Skip to content

Instantly share code, notes, and snippets.

@coffindragger
Created February 9, 2012 04:59
Show Gist options
  • Save coffindragger/1777435 to your computer and use it in GitHub Desktop.
Save coffindragger/1777435 to your computer and use it in GitHub Desktop.
Website allows users to create and manage accounts.
- user manages pubkey
- user is assigned a Git Repo
- can review Stats and Hand Histories
- can refill an empty account with credits 1/day.
User creates Code and pushes to Git Repo.
- using their pubkey to remote: git@sitename.tld:username.git
Simulation runs as a daemon.
- clones all users' Git Repos and evaluate the Code
- instantiate the Lobby and all Players.
- Game Room opens and closes at a set time; number of tables and stakes based on the Daily Schedule.
- each Player banks individually with their controlling User
- no Player can be at more than 1 table at a time.
- Simulation deals the cards and records the Hand Histories in the Data Store.
- a Player gets 1000ms to act.
Visitors can watch Table Simulations from the Website.
- watch all tables, or watch one table
- when new complete hands are finished they are played back at a slower speed.
all Player objects seated at a Table are sent event messages:
"table:newHand"
"hand:dealCards", Player1, [{facedown:true},{facedown:true}]
"hand:dealCards", Player2, [{rank:5,suit:'S',facedown:true},{rank:5,suit:'H',facedown:true}]
"table:smallBlind", Player1, 25
"table:bigBlind", Player2, 50
"table:playerOwes", Player3, 50
Player3 -> "raise, 50"
"hand:raise", Player3, 50
"table:playerOwes", Player4, 100
Player4 -> "fold"
"hand:fold", Player4
"table:playerOwes", Player1, 75
Player1 -> "fold"
"hand:fold", Player1
"table:playerOwes", Player2, 50
Player2 -> "call, 50"
"hand:dealCards", null, [{rank:'a',suit:'S'},{rank:2,suit:'S'},{rank:4,suit:'D'}]
"table:playerOwes", Player2, 0
Player2 -> "check"
"hand:check", Player2
HandHistory = {
number: "XXX"
table: "table:XXX"
'players': [
{'id':'X', 'name':'', 'controller': 'user:X'},
{'id':'X', 'name':'', 'controller': 'user:X'},
],
started: gametime
actions: [
{event: "hand:dealCards", when: gametime, player: "player:XXX", arguments:[
{rank:'N',suit:'S'},{rank:'N',suit:'S'}]},
{event: "hand:dealCards", when: gametime, player: "player:XXX", arguments:[
{rank:'N',suit:'S'},{rank:'N',suit:'S'}]},
{event: "table:smallBlind", when: gametime, player: "player:XXX", arguments:[0.5]},
{event: "table:bigBlind", when: gametime, player: "player:XXX", arguments:[1]},
]
}
Table = {
number: '32de32'
game: 'texas-holdem'
limit: ['nolimit','potlimit','limit']
small_bet: 1
big_bet: 2
small_blind: 0.5
big_blind: 1
ante: 0
seats: 8
players: []
}
Player = {
id: 'XXX'
controller: 'user:XXX'
name: ''
bankroll: 500
seated: true
updated: datetime
source: "filename.js"
}
User = {
id: 'XXX'
username: ''
password: ''
}
SimplePokerBot = extend(PokerPlayer, {
initialize: function() {
global.on("hand:dealCards", this.onDeal)
global.on("table:smallBlind", this.autoPostBlind)
global.on("table:bigBlind", this.autoPostBlind)
global.on("table:youOwe", this.myTurn)
},
onDeal: function(table, player, cards) {
if (!player) { // cards dealt to me
this.my_hand = cards
}
},
autoPostBlind: function(table, player, blind) {
if (player == this.player) {
this.blindToPay = blind;
}
},
myTurn: function(table, amount_owed) {
// raise 3xBB preflop on lucky 7s!
if (table.round == 1 && this.my_hand[0].rank == this.my_hand[1].rank == 7) {
// raise to at least 3 times the big blind, or call anything higher
table.raise(Math.max(table.big_blind*3, amount_owed))
return;
}
// autopost blinds
if (this.blindToPay > 0 && this.blindToPay >= amount_owed) {
this.blindToPay = -1;
table.call(amount_owed)
return;
}
// fold if ace of spades ever shows
if (any(table.board, function(x) { return x.rank == 'A' && x.suit == 'S' })) {
table.fold();
return;
}
//otherwise call anything, maybe we'll get lucky!
if (amount_owed < this.chips_left) {
table.call(amount_owed)
return;
}
// cant afford :(
table.fold()
},
});
bot = new SimplePokerBot;
Lobby.register_player("CallingStation", bot)
Lobby.give_chips(bot, 1000)
Lobby.table()[0].join(bot, 500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment