Esempio n. 1
0
        //==========================================================================
        //internal void PlayChoosers() {
        //  PlayChooser(3, 100, new int[] { 0, -1, 0, -1 });  // full game
        //  PlayChooser(3, 100, new int[] { 0, 3, 0, -1 });
        //  PlayChooser(3, 100, new int[] { 4, 0, 0, -1 });
        //  PlayChooser(3, 100, new int[] { 4, -1 });
        //  PlayChooser(3, 100, new int[] { -1 });  // just the chooser
        //}

        internal void PlayChooser(int loopct, int steparg, int maxdepth, int[] moves)
        {
            //Logger.Level = 2;
            Logger.WriteLine("Play chooser {0} loop={1} step={2} depth={3} moves={4}",
                             Game.Title, loopct, steparg, maxdepth, moves.Join());

            //ShowPosition();
            //ShowMoves();
            Game.NewBoard();
            Game.StepCount = steparg;
            Game.MaxDepth  = maxdepth;
            //Game.NewBoard(ChooserKinds.Mcts, steparg, maxdepth);
            //Logger.Level = 3;
            var treelog = 0;

            foreach (var move in moves)
            {
                Logger.WriteLine("> Board: {0}", Game.PlayedPieces.Join());
                if ((treelog & 1) != 0)
                {
                    ShowTree();
                }
                if (move >= 0)
                {
                    Logger.WriteLine("> Make move {0}", move);
                    ShowMove(Game.GetLegalMove(move));
                    Game.MakeMove(move);
                }
                else
                {
                    if ((treelog & 2) != 0)
                    {
                        ShowTree();
                    }
                    for (int i = 0; i < loopct; i++)
                    {
                        Logger.WriteLine("> UpdateChooser {0} step={1} depth={2}", i, steparg, maxdepth);
                        Game.UpdateChooser();
                        if (Game.ChoicesIter().First().IsDone)
                        {
                            break;
                        }
                    }
                    Logger.WriteLine("> Updated index={0} count={1} weight={2:G5} move={3}",
                                     Game.ChosenMove.Index, Game.VisitCount, Game.Weight, Game.ChosenMove);
                    if ((treelog & 4) != 0)
                    {
                        ShowTree();
                    }
                    ShowMove(Game.GetLegalMove(Game.ChosenMove.Index));
                    Game.MakeMove(Game.ChosenMove.Index);
                }
                if ((treelog & 8) != 0)
                {
                    ShowTree();
                }
            }
        }