public static Situation evaluateSituation(Image tableImage, Table table, List <TableControl> controls, double bigblind) { // street StreetTypes street = getStreetType(table); // hand HandAnalysis analysis = HandEvaluator.evalHandSmart(table.Hand, table.Community); // opponents int opponents = (street == StreetTypes.Preflop ? getPreflopNumberOfOpponents(table) : getPostflopNumberOfOpponents(table)); // action OpponentActionTypes action = (street == StreetTypes.Preflop ? getPreflopOpponentAction(tableImage, table, controls, bigblind) : getPostflopOpponentAction(tableImage, table, controls, bigblind)); // position PositionTypes position = (street == StreetTypes.Preflop ? getPreflopPosition(table) : getPostflopPosition(table)); return(new Situation(street, analysis.HandSmart, analysis.Chance, opponents, action, position)); }
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; }
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); }
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; }
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; }
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); }
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); }
public static void Main(string[] args) { string hand = "2d 2s"; string board = "9d 2h 7s 9s Ts"; StreetTypes street = StreetTypes.River; int opps = 1; OpponentActionTypes action = OpponentActionTypes.Raise; double maxBet = 1.26; double potSize = 0.64; HandAnalysis analysis = HandEvaluator.evalHandSmart(CardParser.parse(hand), CardParser.parse(board)); Console.WriteLine("chance = " + analysis.Chance); Console.WriteLine("basic = " + analysis.HandBasic); Console.WriteLine("smart = " + analysis.HandSmart); List <Rule> rules = RulesReader.readRules(); RuleEvaluator eval = new RuleEvaluator(rules); Rule rule = eval.findRule(street, analysis.HandSmart, analysis.Chance, opps, action, PositionTypes.Early, maxBet, potSize); Console.WriteLine("rule = " + rule.Decision); Console.ReadKey(); }
private string describe(StreetTypes street, HandTypes hand, ChanceTypes chance, int opponents, OpponentActionTypes action) { return(hand + " " + street + " " + chance + " " + opponents + " " + action); }