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 }); }