Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            boardInfo           = new ChessBoard();
            boardInfo.WhoseMove = ChessPieceColor.White;
            boardInfo.pieces    = new ChessPiece[]
            {
                new ChessPiece(ChessPieceType.Rook, 0, true),
                new ChessPiece(ChessPieceType.Knight, 0, true),
                new ChessPiece(ChessPieceType.Bishop, 0, true),
                new ChessPiece(ChessPieceType.Queen, 0, true),
                new ChessPiece(ChessPieceType.King, 0, true),
                new ChessPiece(ChessPieceType.Bishop, 1, true),
                new ChessPiece(ChessPieceType.Knight, 1, true),
                new ChessPiece(ChessPieceType.Rook, 1, true),
                new ChessPiece(ChessPieceType.Pawn, 0, true),
                new ChessPiece(ChessPieceType.Pawn, 1, true),
                new ChessPiece(ChessPieceType.Pawn, 2, true),
                new ChessPiece(ChessPieceType.Pawn, 3, true),
                new ChessPiece(ChessPieceType.Pawn, 4, true),
                new ChessPiece(ChessPieceType.Pawn, 5, true),
                new ChessPiece(ChessPieceType.Pawn, 6, true),
                new ChessPiece(ChessPieceType.Pawn, 7, true),
                null, null, null, null, null, null, null, null,
                null, null, null, null, null, null, null, null,
                null, null, null, null, null, null, null, null,
                null, null, null, null, null, null, null, null,
                new ChessPiece(ChessPieceType.Pawn, 0, false),
                new ChessPiece(ChessPieceType.Pawn, 1, false),
                new ChessPiece(ChessPieceType.Pawn, 2, false),
                new ChessPiece(ChessPieceType.Pawn, 3, false),
                new ChessPiece(ChessPieceType.Pawn, 4, false),
                new ChessPiece(ChessPieceType.Pawn, 5, false),
                new ChessPiece(ChessPieceType.Pawn, 6, false),
                new ChessPiece(ChessPieceType.Pawn, 7, false),
                new ChessPiece(ChessPieceType.Rook, 0, false),
                new ChessPiece(ChessPieceType.Knight, 0, false),
                new ChessPiece(ChessPieceType.Bishop, 0, false),
                new ChessPiece(ChessPieceType.Queen, 0, false),
                new ChessPiece(ChessPieceType.King, 0, false),
                new ChessPiece(ChessPieceType.Bishop, 1, false),
                new ChessPiece(ChessPieceType.Knight, 1, false),
                new ChessPiece(ChessPieceType.Rook, 1, false),
            };

            PieceMoves.InitiateChessPieceMotion();
            PieceValidMoves.GenerateValidMoves(boardInfo);
            Evaluation.EvaluateBoardScore(boardInfo);

            boardHistory.Add(new ChessBoard(boardInfo));

            base.Initialize();
        }
Exemple #2
0
    static void Main(string[] args)
    {
        using (new MPI.Environment(ref args))
        {
            Intracommunicator comm = Communicator.world;

            if (comm.Rank == 0)
            {
                RunEngine();

                for (int i = 1; i < comm.Size; i++)
                {
                    comm.Send(new InterProcessData()
                    {
                        ShallQuit = true
                    }, i, 0);
                }
            }
            else
            {
                PieceMoves.InitiateChessPieceMotion();

                while (true)
                {
                    var data = comm.Receive <InterProcessData>(0, 0);

                    if (data.ShallQuit)
                    {
                        break;
                    }

                    MoveContent bestMove = Search.Execute(data.ExamineBoard, data.pos, data.depth, data.GameBook);
                    comm.Send(bestMove, 0, 0);
                }
            }
        }
    }