I write poker environments in C # and I don’t like the design I have. My goal is to have a game engine that can quickly launch multiple AI agents against each other in batch mode and play multiple AI agents against several people (possibly through the Silverlight client). I would like to increase efficiency, but maintain flexibility - for example, it should be able to play games such as Limit Hold'em, No-Limit Hold'em, Limit 7-Card Stud, etc.
My current design is pretty awkward and inflexible:
- HandHistory: contains all the information about the current hand (players, bets made, etc.).
- IPlayer: each player defines a GetAction (HandHistory history) method.
- GameEngine: Defines a Play (HandInfo info) method that returns a HandHistory object.
- PotManager: manages the bank and determines how much each player needs and how much they can win (for example, if they have unequal stacks and all-in).
- BetManager: manages bets and determines when a round of betting is completed.
The HandInfo class contains all the information on how to set up your hand. Then the Play method looks something like this:
HandHistory Play(HandInfo info) { PotManager pots = new PotManager(info); BetManager bets = new BetManager(info); HandHistory history = CreateHistory(info); bets.CollectBlinds(); if(!bets.GameOver) { DealHoleCards(); if(bets.PlayersThatCanStillBet > 1) bets.CollectBets(); if(!bets.GameOver) { DealFlop(); ... and on and on } } return history; }
Problems arise because there are so many things to consider, such as collecting blinds, etc. The Pot and Bet manager classes become a nightmare and are invariably riddled with bugs. In addition, my engine design only supports one type of game (Hold'em), unlike the others.
My top ranking is the first for efficiency, as the engine is used primarily as an AI simulator over billions of hands. However, I would like to think that there is a more elegant way in which this could be done.
c # oop poker
Wesley tansey
source share