Example #1
0
 public Situation(StreetTypes street, HandTypes hand,
                  ChanceTypes chance, int opponents,
                  OpponentActionTypes action, PositionTypes position)
 {
     this.street    = street;
     this.hand      = hand;
     this.chance    = chance;
     this.opponents = opponents;
     this.action    = action;
     this.position  = position;
 }
Example #2
0
        public static List <Rule> readRules()
        {
            Log.Info("Reading spreadsheet '" + RULES_XLS + "'");
            Workbook    workbook  = Workbook.Load(RULES_XLS);
            Worksheet   worksheet = workbook.Worksheets[0];
            List <Rule> rules     = new List <Rule>();
            int         row       = 1;

            while (true)
            {
                // check
                if (isEmptyRow(worksheet, row))
                {
                    break;
                }
                Log.DebugIf(row % 100 == 0, "Reading row '" + (row + 1) + "'");

                // columns
                string hand     = worksheet.Cells[row, 2].StringValue;
                string street   = worksheet.Cells[row, 3].StringValue;
                string pot      = worksheet.Cells[row, 4].StringValue;
                string board    = worksheet.Cells[row, 5].StringValue;
                string opps     = worksheet.Cells[row, 6].StringValue;
                string action   = worksheet.Cells[row, 7].StringValue;
                string position = worksheet.Cells[row, 8].StringValue;
                string maxbet   = worksheet.Cells[row, 9].StringValue;
                string potsize  = worksheet.Cells[row, 10].StringValue;
                string decision = worksheet.Cells[row, 11].StringValue;

                // map
                StreetTypes         streetType   = mapStreetType(street);
                HandTypes           handType     = mapHandType(hand);
                ChanceTypes         chanceType   = mapChanceType(board);
                int                 minOpponents = mapMinOpponents(opps);
                int                 maxOpponents = mapMaxOpponents(opps);
                OpponentActionTypes actionType   = mapActionType(action);
                PositionTypes       positionType = mapPositionType(position);
                double              minMaxBet    = mapMinInterval(maxbet);
                double              maxMaxBet    = mapMaxInterval(maxbet);
                double              minPotSize   = mapMinInterval(potsize);
                double              maxPotSize   = mapMaxInterval(potsize);

                // rule
                Rule rule = new Rule(streetType, handType, chanceType, minOpponents,
                                     maxOpponents, actionType, positionType, minMaxBet, maxMaxBet,
                                     minPotSize, maxPotSize, decision);
                rules.Add(rule);

                // next
                row++;
            }
            Log.Info("Done reading spreadsheet");
            return(rules);
        }
Example #3
0
 public Rule(StreetTypes street, HandTypes hand,
             ChanceTypes chance, int minOpps, int maxOpps,
             OpponentActionTypes action)
 {
     this.street   = street;
     this.hand     = hand;
     this.chance   = chance;
     this.minOpps  = minOpps;
     this.maxOpps  = maxOpps;
     this.action   = action;
     this.decision = NO_RULE;
 }
Example #4
0
		public static HandAnalysis evalHandSmart(List<Card> hand, List<Card> board)
		{
            // preflop
            if(board.Count == 0)
            {
                Log.Fine("evaluating preflop cards -> {" + map(hand) + "}");
    			HandTypes smart = SmartEvaluator.evalHand(map(hand));
    			return new HandAnalysis(smart);
            }
			// postflop
            else
            {
                Log.Fine("evaluating postflop cards -> {" + map(hand) + "}  {" + map(board) + "}");
    			Hand.HandTypes basic = evalHand(hand, board).HandTypeValue;
    			HandTypes smart = SmartEvaluator.evalHand(basic, map(hand), map(board));
                ChanceTypes chance = SmartEvaluator.evalChance(hand, smart, map(board));
    			return new HandAnalysis(basic, smart, chance);
            }
		}
Example #5
0
 public Rule(StreetTypes street, HandTypes hand,
             ChanceTypes chance, int minOpps, int maxOpps,
             OpponentActionTypes action,
             PositionTypes position,
             double minMaxBet, double maxMaxBet,
             double minPotSize, double maxPotSize,
             string decision)
 {
     this.street     = street;
     this.hand       = hand;
     this.chance     = chance;
     this.minOpps    = minOpps;
     this.maxOpps    = maxOpps;
     this.action     = action;
     this.position   = position;
     this.minMaxBet  = minMaxBet;
     this.maxMaxBet  = maxMaxBet;
     this.minPotSize = minPotSize;
     this.maxPotSize = maxPotSize;
     this.decision   = decision;
 }
Example #6
0
        public Rule findRule(StreetTypes street, HandTypes hand,
                             ChanceTypes chance, int opponents,
                             OpponentActionTypes action,
                             PositionTypes position,
                             double maxBet, double potSize)
        {
            // hash
            int hash = getHashCode(street, hand, chance, opponents, action, position);

            if (!rules.ContainsKey(hash))
            {
                Log.Debug("cannot find rule for this constellation -> "
                          + describe(street, hand, chance, opponents, action));
                return(new Rule(street, hand, chance, opponents, opponents, action));
            }

            // intervals
            MaxBetDictionary  maxBetDict  = rules[hash];
            PotSizeDictionary potSizeDict = maxBetDict.getByInterval(maxBet);
            Rule rule = potSizeDict.getByInterval(potSize);

            return(rule);
        }
Example #7
0
        private int getHashCode(StreetTypes street, HandTypes hand,
                                ChanceTypes chance, int opponents,
                                OpponentActionTypes action,
                                PositionTypes position)
        {
            // ints
            int streetNum = (int)street;
            int handNum   = (int)hand;
            int chanceNum = (int)chance;
            int actionNum = (int)action;
            int posNum    = (int)position;

            // bits
            int bits = (streetNum & mask(4));

            bits |= (handNum & mask(6)) << 4;
            bits |= (chanceNum & mask(4)) << 10;
            bits |= (opponents & mask(4)) << 14;
            bits |= (actionNum & mask(4)) << 18;
            bits |= (posNum & mask(2)) << 22;

            // hash
            return(bits);
        }
Example #8
0
 public HandAnalysis(Hand.HandTypes basic, HandTypes smart, ChanceTypes chance)
 {
     this.basic  = basic;
     this.smart  = smart;
     this.chance = chance;
 }
Example #9
0
 private string describe(StreetTypes street, HandTypes hand,
                         ChanceTypes chance, int opponents,
                         OpponentActionTypes action)
 {
     return(hand + " " + street + " " + chance + " " + opponents + " " + action);
 }