I put the code in here:
https://github.com/rgonzalez72/omaha
This is how I did it step by step. I wrote the bot using object oriented python.
Basic classes
I created a number of classes to deal with the poker card. They are Suit, Height, Card, Hand and Maze. These classes are simple enough and they don't require further explanation.Hand evaluation
The class Evaluate performs the evaluation of the hands. I copied the evaluation functions from the "getting started" code of the competion. The trick here is representing every hand and the rank as a 32 bit map in a way they can be compared. This is done in the eval5 function.There is another function called eval9 that calculates the best score considering the four card in the hand and the five on the table according to the Omaha rules. That is why we need the getCouples and getTrios functions in the Hand class.
Probabilities calculation
This section describes how the probabilities of my hand is calculated. We'll I don't, I just estimate them after running a number of random games and counting the winning and losing hands. This is done in the calProbabilies function.Fuzzy logic implementation
We have all the basic poker functionallity implemented so far. What we need now is to define the strategy. I decided to use fuzzy logic for the simple reason that I had never used it before and wanted to become familiar with it. First I was considering using some library but I could not be sure the library would be available in the competition servers so I implemented my basic fuzzy logic module.The module defines fuzzy variables and operators. The variables can be triangles or trapezoids. The inputSet and outputSet classes are arrays of variables.
Fuzzy logic rules
Finally, with all the elements described, we can't define the rules that make our program "intelligent".Type of game
The first set of input rules we define is the number of chips in the pot that can be FEW, AVERAGE, LOTS. Depending on the number of chips we change the way we play that can be SUICIDAL, AGGRESIVE, CAUTIOUS and CONSERVATIVE. The rules are defined in GameTypeCalculator.This strategy proved to be not too good and was later dropped the Bot is always AGGRESIVE.
ActionCalculator
The action calculator uses two inputSet: the game type and the hand probability. The hand probability can be VERY GOOD, GOOD, REGULAR and BAD. The goodness of the hand based on the probability is different in the phases of the game, that is why we have defined different ranges for pre-flop, flop, turn and river. The output set is the action: FOLD, CALL, RAISE MIN, RAISE MED, RAISE MAX. Please see ActionCalculator class and its children for details.And that is, the rest of code is used to deal with the Bot interface. We've implemented a reasonable poker player in 1200 lines of code.
No hay comentarios:
Publicar un comentario