From 6701e8cbb8a6fa47ddd649dd17094749a576f601 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Sep 2016 03:45:43 +0300 Subject: [PATCH 1/3] add evBot --- players/challengerBot.js | 88 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 8 deletions(-) diff --git a/players/challengerBot.js b/players/challengerBot.js index 74b45d4..196971e 100644 --- a/players/challengerBot.js +++ b/players/challengerBot.js @@ -1,17 +1,89 @@ module.exports = function () { var info = { - name: "Nameless Challenger", - email: "", - btcWallet: "" + name: "evBot", + email: "evbot@noman.land", + btcWallet: "nil" }; - + + // I hope these don't count as "external modules"? + // they seem to come with the game engine + var Hand = require('hoyle').Hand; + var deck = new (require('hoyle').Deck)().cards; + + // increadably bad card dealer + function randCard(used) { + while(true) { + var card = deck[Math.floor(Math.random()*deck.length)].toString(); + if(used.indexOf(card) == -1) + { + used.push(card); + return card; + } + } + } + + // slowest game simulator on the planet + // needs serious optimizations + function simulate(hand, community, opponents, iterations) { + var wins = 0; + var games = 0; + var used = hand.concat(community); + + for(games=0; games pot += parseFloat(p.wagered)); + + // compensate for horrible pre-flop and flop + // reducing opponent count increases simulation winning odds + var num_opponents = game.players.filter(p => p.state == 'active').length; + var sim_opponents = Math.min(num_opponents, opponent_cap); + + // calculate winning odds + var odds = simulate(game.self.cards, game.community, sim_opponents, sim_iterations); + + // set bet + // I have no idea if this is actually a good strategy or + // if it's just good against these basic bots + return pot * odds * aggression; } } - return { update: update, info: info } - -} + return { update: update, info: info }; + +}; From 7086b53cab34bef6dd64ccb8cba11d1832cc6d3f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Sep 2016 03:51:55 +0300 Subject: [PATCH 2/3] Add submodule hacks to work with old node --- players/challengerBot.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/players/challengerBot.js b/players/challengerBot.js index 196971e..c7eb008 100644 --- a/players/challengerBot.js +++ b/players/challengerBot.js @@ -6,10 +6,13 @@ module.exports = function () { btcWallet: "nil" }; - // I hope these don't count as "external modules"? - // they seem to come with the game engine - var Hand = require('hoyle').Hand; - var deck = new (require('hoyle').Deck)().cards; + // Haxx - get submodule on old node + // I hope these don't count as "external modules" + // as they come with the game engine + var mp = require.cache[require.resolve('machine-poker')] + var hoyle = mp.require('hoyle') + var Hand = hoyle.Hand; + var deck = new (hoyle.Deck)().cards; // increadably bad card dealer function randCard(used) { @@ -67,11 +70,11 @@ module.exports = function () { // calculate pot size var pot = 0; - game.players.map(p => pot += parseFloat(p.wagered)); + game.players.map(function(p) { return pot += parseFloat(p.wagered); }); // compensate for horrible pre-flop and flop // reducing opponent count increases simulation winning odds - var num_opponents = game.players.filter(p => p.state == 'active').length; + var num_opponents = game.players.filter(function(p) { return p.state == 'active'; }).length; var sim_opponents = Math.min(num_opponents, opponent_cap); // calculate winning odds From 02230be90416f7425b112010abce41f715af8e04 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Sep 2016 18:30:29 +0300 Subject: [PATCH 3/3] Further reduce simulation count to avoid timeouts on travis --- players/challengerBot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/players/challengerBot.js b/players/challengerBot.js index c7eb008..a25bdcf 100644 --- a/players/challengerBot.js +++ b/players/challengerBot.js @@ -61,7 +61,7 @@ module.exports = function () { // simulation results are just above random var aggression = 1; var opponent_cap = 1; - var sim_iterations = 20; + var sim_iterations = 15; // if you have a proper simulator... these will do much better //var aggression = 1.25;