Esempio n. 1
0
        void Initialize()
        {
            DateTime startTime = DateTime.Now;

            _at = ActionTree.Read <ActionTree>(ActionTreeFile);
            if (IsVerbose)
            {
                Console.WriteLine("Action tree: {0}", _at.Version.ToString());
            }
            _init             = new InitData(this);
            _playersCount     = _at.PlayersCount;
            _epsilonLog       = new List <EpsilonLogEntry>();
            _snapshotSwitcher = new SnapshotSwitcher(OutputPath, GetSnapshotHeaderFileName(), SnapshotsCount);
            _curSnapshotInfo  = new SnapshotInfo(_snapshotSwitcher.CurrentSnapshotPath, _playersCount);
            IterationCounts   = new int[_playersCount];
            LastBrValues      = new double[_playersCount];
            _ptExt            = new Node[_playersCount][];

            _rng       = new System.Random(RngSeed);
            _mcDealer  = new McDealer(GameDef, _rng);
            _hands     = new int[_playersCount][].Fill(i => new int[_mcDealer.HandSize]);
            _handSizes = GameDef.GetHandSizes();
            _oppGv     = new double[_at.NodesCount];

            bool isNewSnapshot = !_snapshotSwitcher.IsSnapshotAvailable;

            if (isNewSnapshot)
            {
                CreateNewSnapshot();
            }
            //LoadSnapshot();

            CreatePlayerTrees();

            for (int p = 0; p < _playersCount; ++p)
            {
                if (TraceDir != null)
                {
                    Vis.Show(this, p, GetTraceFileName(p, "tree", "init-pt", "gv"));
                }
            }
            if (TraceDir != null)
            {
                VisChanceTree.Show(_init.PlayerCt, GetTraceFileName(0, "pct", "", "gv"));
            }

            PrintInitDone();

            // Clean-up
            _init = null;
            double time = (DateTime.Now - startTime).TotalSeconds;

            if (IsVerbose)
            {
                Console.WriteLine("Initialization done in {0:0.0} s", time);
            }
        }
Esempio n. 2
0
 public static void Show(FictitiousPlayMc solver, int position, string fileName)
 {
     using (TextWriter w = new StreamWriter(File.Open(fileName, FileMode.Create)))
     {
         Vis vis = new Vis {
             Output = w, Solver = solver, Position = position
         };
         vis.Show(solver._pt);
     }
 }
Esempio n. 3
0
        private void BestResponse()
        {
            BestResponseValuesUp();
            BestResponseFinalize();

            if (TraceDir != null)
            {
                Vis.Show(this, _heroPos, GetTraceFileName(_heroPos, "tree", "", "gv"));
            }
        }
Esempio n. 4
0
            public static void Show(GameValue solver, int position, string fileName)
            {
                StrategyTree t = solver.Strategies[position];

                using (TextWriter w = new StreamWriter(File.Open(fileName, FileMode.Create)))
                {
                    Vis vis = new Vis {
                        Output = w, Solver = solver, Position = position
                    };
                    vis.Show(t);
                }
            }
Esempio n. 5
0
            public static void Show(Br solver, string fileName)
            {
                StrategyTree t = solver.Strategies[solver.HeroPosition];

                using (TextWriter w = new StreamWriter(File.Open(fileName, FileMode.Create)))
                {
                    Vis vis = new Vis {
                        Output = w, Solver = solver
                    };
                    vis.Show(t);
                }
            }
Esempio n. 6
0
 private void PrintInitDone()
 {
     if (TraceDir != null)
     {
         for (int p = 0; p < _playersCount; ++p)
         {
             Vis.Show(this, p, GetTraceFileName(p, "tree", "init-done", "gv"));
         }
     }
     if (IsVerbose)
     {
         for (int p = 0; p < _playersCount; ++p)
         {
             Console.WriteLine("Data structures pos {0}:", p);
             Console.WriteLine("Player tree nodes: {0:#,#}", _pt.NodesCount);
         }
     }
 }