Exemplo n.º 1
0
        public VariantDBoard(VariantDBoard other)
        {
            board = new GameToken[other.board.Length];
            Array.Copy(other.board, board, other.board.Length);

            numWhitePieces = other.numWhitePieces;
            numBlackPieces = other.numBlackPieces;
            numWhiteMoves = other.numWhiteMoves;
            numBlackMoves = other.numBlackMoves;
            isOpening = other.isOpening;
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string inputFile;
            string outputFile;
            int treeDepth;
            string inputBoardAsAtring = "xxxxxxxxxWxxxxxxBxxxxxx";

            if (args.Length < 3)
            {
                inputFile = "board1.txt";
                outputFile = "board2.txt";
                treeDepth = 3;
            }
            else
            {
                inputFile = args[0];
                outputFile = args[1];
                treeDepth = Convert.ToInt32(args[2]);
            }

            // read the board as a string from the input file
            inputBoardAsAtring = System.IO.File.ReadAllLines(@"" + inputFile)[0];

            var board = new VariantDBoard(true, inputBoardAsAtring);
            Console.WriteLine(board.Print());

            var movesGen = new MoveGenerator<VariantDBoard>(VariantDMoveGenerator<VariantDBoard>.Moves);
            var blackGen = new MoveGenerator<VariantDBoard>(VariantDMoveGenerator<VariantDBoard>.BlackMove);
            var root = new GameNode<VariantDBoard>(board, null, treeDepth, movesGen, blackGen, true);
            var minmax = new MiniMax.MiniMax<VariantDBoard>(true);
            var score = minmax.MiniMaxBase(root);
            var move = score.Item1.GetParentAtDepth(1);

            Console.WriteLine("Nodes generated: " + root.NumNodes() + ".");

            Console.WriteLine(move.Board.Print());

            string[] lines =
                { "Board Position: " + move.Board.ToString(),
                    "Positions evaluated by static estimation: " + minmax.StaticEvals + ".",
                    "MINIMAX estimate: " + score.Item2 + "."
                };
            foreach (var line in lines)
            {
                Console.WriteLine(line);
            }
            System.IO.File.WriteAllLines(@"" + outputFile, lines);
        }