private void OnDeal(string cards) { _sei.Reset(); _pocket = StdDeck.Descriptor.GetCardSet(cards); _sePocket = _sei.Convert(_pocket); _pocketKind = HePockets.CardSetToPocketKind(_sePocket); log.InfoFormat("{0} OnDeal() pocket {1} iso {2} kind {3}", _name, _pocket, _sePocket, _pocketKind); }
public int GetBucket(CardSet pocket, CardSet board, int round) { int bucket; if (round == 0) { // preflop bucket = (int)HePockets.CardSetToPocketKind(pocket); } else { float hs = HandStrength.CalculateFast(pocket, board); bucket = (int)(BucketCount[round] * hs); if (bucket == BucketCount[round]) { bucket--; // Special correction for a single HS value of 1.0 } } return(bucket); }
private static void MonteCarlo() { // Create new arrays for preflop values for (int pos = 0; pos < 2; ++pos) { _createPreflopValues.Walk(_neytiri, _neytiri.Positions[pos]); } DateTime start = DateTime.Now; for (int ourPos = 0; ourPos < _neytiri.Positions.Length; ++ourPos) { Console.WriteLine("Position {0}", ourPos); ActionTreeNode root = _neytiri.Positions[1 - ourPos]; List <ActionTreeNode> strategyPath = new List <ActionTreeNode>(100); strategyPath.Add(root); // Advance to the node where we get cards while (strategyPath[strategyPath.Count - 1].State.CurrentActor != ourPos) { strategyPath.Add(strategyPath[strategyPath.Count - 1].Children[0]); } for (HePocketKind pocketKind = 0; pocketKind < HePocketKind.__Count; ++pocketKind) { CardSet pocket = HePockets.PocketKindToCardSet(pocketKind); if (_pockets.Count > 0 && !_pockets.Contains(pocket)) { // Skip the pocket if command line specifies which pockets to include and it's not there. continue; } Console.Write("{0} ", pocketKind.ToString().Substring(1)); MonteCarloStrategyFinder.DoMonteCarlo(_neytiri, ourPos, pocket, 0, "", strategyPath, _cmdLine.mcCount); WalkTree <ActionTree, ActionTreeNode, int> copyValues = new WalkTree <ActionTree, ActionTreeNode, int> { OnNodeBegin = (t, n, s, d) => { if (n.State.Round > 0) { return(false); } n.PreflopValues[(int)pocketKind] = n.Value; return(true); } }; copyValues.Walk(_neytiri, root); } Console.WriteLine(); } DateTime finish = DateTime.Now; double sec = (finish - start).TotalSeconds; Console.WriteLine("Done {0} monte-carlo trials for every pocket in each position in {1:0.0} sec", _cmdLine.mcCount, sec); Console.WriteLine("Writing Neytiri strategy to {0} ...", _cmdLine.neytiri); _neytiri.XmlSerialize(_cmdLine.neytiri, new XmlWriterSettings { Indent = false }); }