예제 #1
0
        static void MoveGeneratorTestTwo()
        {
            Position testPosition = FENParser.ParseFEN("7k/8/8/6p1/5pP1/5Pn1/6PN/7K w - - 0 1".Split(' '));

            foreach ((Position position, Move move) in testPosition.GeneratePositions())
            {
                ConsoleGraphics.DrawPosition(position);
            }
            Console.ReadKey();
        }
예제 #2
0
        static void GameClassTest()
        {
            float[][] weights = new float[][] { new float[] { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }, new float[] { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }, new float[] { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f } };
            Game      game    = new Game
            {
                currentPosition = FENParser.ParseFEN("3r2k1/6P1/6PB/6PK/6PP/8/8/8 b - - 0 1"),
                whitePlayer     = new NeuralNetwork(2, 2, 2, 2, weights.Select(s => s.ToArray()).ToArray()),
                blackPlayer     = new NeuralNetwork(2, 2, 2, 2, weights.Select(s => s.ToArray()).ToArray())
            };

            game.Play();
        }
예제 #3
0
        private static void InputPosition(string[] inputStringArray)
        {
            Position position;
            int      firstMove;

            if (inputStringArray[0] == "fen")
            {
                List <String> FENStringList = new List <String>();
                for (int i = 1; i <= 6; i++)
                {
                    FENStringList.Add(inputStringArray[i]);
                }
                position  = FENParser.ParseFEN(FENStringList.ToArray());
                firstMove = 8;
            }
            else
            {
                position  = new Position();
                firstMove = 2;
            }

            Move   move;
            string moveString;

            for (int i = firstMove; i < inputStringArray.Length; i++)
            {
                moveString = inputStringArray[i];
                move       = new Move(COORDINATE_TRANSFORMATION(moveString[0]), 8 - (int)Char.GetNumericValue(moveString[1]), COORDINATE_TRANSFORMATION(moveString[2]), 8 - (int)Char.GetNumericValue(moveString[3]), position.board[COORDINATE_TRANSFORMATION(moveString[0]), 8 - (int)Char.GetNumericValue(moveString[1])]);
                if ((move.pieceToMove == WHITE_PAWN || move.pieceToMove == BLACK_PAWN) && move.toX == position.enPassantSquare.Item1 && move.toY == position.enPassantSquare.Item2)
                {
                    move.enPassantCapture = true;
                }
                if (moveString.Length >= 5)
                {
                    if (position.toMove == WHITE)
                    {
                        move.newPiece = INVERSED_PIECE_REPRESENTATIONS(Char.ToUpper(moveString[4]));
                    }
                    else
                    {
                        move.newPiece = INVERSED_PIECE_REPRESENTATIONS(moveString[4]);
                    }
                }
                position = position.MakeMove(move);
            }
            currentPosition = position;
        }