예제 #1
0
        public GameState Clone()
        {
            var newboard = new SquareState[8, 8];

            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    newboard[x, y] = new SquareState
                    {
                        Piece    = _board[x, y].Piece,
                        Position = _board[x, y].Position,
                    };
                }
            }

            var newTakenPieces = new List <IPiece>();

            newTakenPieces.AddRange(_takenPieces);

            return(new GameState(newboard, newTakenPieces, _playerTurn));
        }
예제 #2
0
        public void Initialize()
        {
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    _board[x, y] = new SquareState {
                        Piece = null
                    };
                }
            }

            Team top    = Team.Black;
            Team bottom = Team.White;

            for (int x = 0; x < 8; x++)
            {
                _board[x, 1] = new SquareState {
                    Piece = new Pieces.Pawn(top, Direction.Down)
                };
            }
            _board[0, 0] = new SquareState {
                Piece = new Pieces.Rook(top)
            };
            _board[7, 0] = new SquareState {
                Piece = new Pieces.Rook(top)
            };
            _board[1, 0] = new SquareState {
                Piece = new Pieces.Knight(top)
            };
            _board[6, 0] = new SquareState {
                Piece = new Pieces.Knight(top)
            };
            _board[2, 0] = new SquareState {
                Piece = new Pieces.Bishop(top)
            };
            _board[5, 0] = new SquareState {
                Piece = new Pieces.Bishop(top)
            };
            _board[3, 0] = new SquareState {
                Piece = new Pieces.King(top)
            };
            _board[4, 0] = new SquareState {
                Piece = new Pieces.Queen(top)
            };


            for (int x = 0; x < 8; x++)
            {
                _board[x, 6] = new SquareState {
                    Piece = new Pieces.Pawn(bottom, Direction.Up)
                };
            }
            _board[0, 7] = new SquareState {
                Piece = new Pieces.Rook(bottom)
            };
            _board[7, 7] = new SquareState {
                Piece = new Pieces.Rook(bottom)
            };
            _board[1, 7] = new SquareState {
                Piece = new Pieces.Knight(bottom)
            };
            _board[6, 7] = new SquareState {
                Piece = new Pieces.Knight(bottom)
            };
            _board[2, 7] = new SquareState {
                Piece = new Pieces.Bishop(bottom)
            };
            _board[5, 7] = new SquareState {
                Piece = new Pieces.Bishop(bottom)
            };
            _board[3, 7] = new SquareState {
                Piece = new Pieces.King(bottom)
            };
            _board[4, 7] = new SquareState {
                Piece = new Pieces.Queen(bottom)
            };
        }