   Object Oriented Poker - AI Poker Bot Challenge!
  Hello,I've done something I wanted to do a long time: Make a game where people can program Texas Hold'm poker bots that can battle each other.The engine is called "OOPoker", which stands for "Object Oriented Poker" (because the AI you program has to implement an interface).You can program bots in C++ in this game, and then let them play against each other for a settable amount of rounds. At the end, statistics are shown and a winning bot is declared!It's also possible to play against the bot as human.If you're interested, please program your own bot, and post the source code here, so other people can try it out and pit it against their own bots!I'd love people to program bots for two reasons:*) To entertain me, I'd love to play against GOOD bots! My cellular phone has a poker game, but the bots are annoying and predictable, that is not fun.*) To let bots battle against each other to find the Best Bot, to create a sort of challenge, where the best bot wins, and can be beaten again later if someone implements a better one, etc...Please note that this poker engine doesn't work for existing online internet games. I know there exist controversial bots that can win money online automatically, but that isn't my intention with this game. Here's an article by a guy who did just that: http://www.codingthewheel.com/archives/how-i-built-a-working-poker-bot.Instructions to create a bot:Get the source code from sourceforge from SVN (http://oopoker.svn.sourceforge.net/viewvc/oopoker/) or download it as zip here (https://sourceforge.net/projects/oopoker/files/).Open the code in your IDE (a Code::Blocks project file is provided).Create a new implementation of the "AI" class, and implement smart functionality.Various poker math functions are available to help you implement your bot, including the fastest hand evaluator in existance to calculate pot equity!A reasonable example AI is included, "AISmart". Here is its code, as an example (to tempt you into getting this source code and improve it!)/*OOPokerCopyright (c) 2010 Lode VandevenneAll rights reserved.This file is part of OOPoker.OOPoker is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.OOPoker is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with OOPoker.  If not, see <http://www.gnu.org/licenses/>.*/#include "ai_smart.h"#include "info.h"#include "random.h"#include "pokermath.h"#include <iostream>AISmart::AISmart(double tightness): tightness(tightness){}Action AISmart::doTurn(const Info& info){  /*  The "Smart" AI tries to win by playing with good cards and folding with bad cards.  This AI is called smart because it's smart compared to the Naive demo AI's. However, it  isn't that smart at all, the intention is that *you* make a smarter one!  Some hints for better AI's:  -use pot equity / odds  -have a memory, to enable strategies that take multiple turns, such as check-raise  -use Harrington zones  -use position compared to the dealer  -take the amount of opponents into account  -try to keep track of playing style of other players, recognise individual players  -change strategy every now and then to try not to be too predictable  -detect when an opponent is weak and can be outbluffed  */  double raiseChance = 0.0;  double allInChance = 0.0;  int maxWager = 0; //for calling  int bb = info.getBigBlind();  if(info.round == R_PRE_FLOP)  {    int group = getSklanskyMalmuthGroup(info.handCard1, info.handCard2);    if(group == 9) maxWager = 0;    else if(group == 8 || group == 7) maxWager = bb;    else if(group == 6 || group == 5)    { maxWager = bb * 4; raiseChance = 0.2;    }    else if(group == 4 || group == 3)    { maxWager = info.getStack() + info.getWager(); raiseChance = 0.5; allInChance = 0.1;    }    else if(group == 2 || group == 1)    { maxWager = info.getStack() + info.getWager(); raiseChance = 0.5; allInChance = 0.2;    }  }  else  {    double win, tie, lose;    int num_opponents = info.getNumActivePlayers() - 1;    if(info.round == R_FLOP) getWinChanceAgainstNAtFlop(win, tie, lose, info.handCard1, info.handCard2, info.tableCard1, info.tableCard2, info.tableCard3, num_opponents);    else if(info.round == R_TURN) getWinChanceAgainstNAtTurn(win, tie, lose, info.handCard1, info.handCard2, info.tableCard1, info.tableCard2, info.tableCard3, info.tableCard4, num_opponents);    else if(info.round == R_RIVER) getWinChanceAgainstNAtRiver(win, tie, lose, info.handCard1, info.handCard2, info.tableCard1, info.tableCard2, info.tableCard3, info.tableCard4, info.tableCard5, num_opponents);//reduce win chance a bit if there are more players    if(win < 0.9) win /= (1.0 + info.getNumActivePlayers() / 5.0);if(win > tightness)    { maxWager = info.getStack() + info.getWager(); raiseChance = 0.5; allInChance = 0.5;    }    else if(win > tightness / 2)    { maxWager = (info.getStack() + info.getWager()) / 3; raiseChance = 0.2;    }    else if(tie > 0.8)    { //large chance to tie (maybe there's a royal flush on the table or so). Never fold in this case! raiseChance = 0; allInChance = 0; maxWager = info.getStack() + info.getWager();    }    else //misery... only check or fold    { maxWager = 0;    }  }  int minWagerTotal = info.getWager() + info.getCallAmount();  if(minWagerTotal > info.getWager() + info.getStack()) minWagerTotal = info.getWager() + info.getStack();  if(minWagerTotal > maxWager)  {    return info.getCheckFoldAction();  }  else  {    if(getRandom() < raiseChance)    { int amount = (int)(info.getMinChipsToRaise() * (1.0 + getRandom())); //round the amount to become a multiple of big blinds amount = (amount / bb) * bb; if(amount == 0) amount = info.getMinChipsToRaise(); return info.amountToAction(amount);    }    else if(getRandom() < allInChance)    { return info.getAllInAction();    }    else    { return info.getCallAction();    }  }  return info.getCheckFoldAction();}std::string AISmart::getAIName(){  return "Smart";}And finally, here's a screenshot of a session in action:[Edited by - Lode on May 9, 2010 11:51:19 AM]
  Are you using OpenGL or D3D?   ;  cool idea.   ;Quote:Original post by irreversibleAre you using OpenGL or D3D?A good question, you'd really wonder what library could render such nice letters!But seriously, the code structure makes it reasonably easy to create a graphical client that would use OpenGL or D3D to provide the user I/O. In fact, the human player is just an AI implementation, and it's possible to create an AI implementation that asks the user what Action to do in any way, be it graphically, with text, in 3D, through a webserver, or anything else...I might implement a fancier user interface later, probably with SDL and/or OpenGL.But for now the focus is on the math and the poker!   ;  As a former semi-professional multi-table grinder, I might take a shot if I can find the time.It's a sit 'n go format right, not cash? In that case I'll see if I can make an ICM pushbot implementation. :)   ;  BTW, in case your bot can't seem to come to a decision:/* pokermath.cpp line 894 */ComboType eval4_2_5_3_category(int result){  return eval4_2_5_3_category(result);}:)   ;  I'm working on a poker bot at the moment, and part of the project is creating a simulator where multiple bots can play each other, just like you've made.If I get time I'll hook the AI i'm working on up to your program and see how it does.   ;  - design awesome poker bot.- join internet poker tournaments.- ???- profit!;  - design awesome poker bot.- join internet poker tournaments.- Realise my poker bot sucks.- Improve poker bot AI for next 5 years- (maybe) profit?!   ;  - Create subscription-based poker site.- ...zzz...- Profit.Sorry for not being more constructive - it's just that I think poker's not primarily about probablity or luck, or playing cards - it's about playing people and, to me, having fun doing that.   