示例#1
0
        public override bool[,] PossibleMoves()
        {
            bool[,] mat = new bool[Board.Rows, Board.Columns];

            Position pos = new Position(0, 0);

            if (Color == Color.White)
            {
                pos.DefinePosition(Position.Row - 1, Position.Column);
                if (Board.ValidPosition(pos) && CanMove(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }

                pos.DefinePosition(Position.Row - 2, Position.Column);
                if (Board.ValidPosition(pos) && CanMove(pos) && NumberOfMoves == 0)
                {
                    mat[pos.Row, pos.Column] = true;
                }

                pos.DefinePosition(Position.Row - 1, Position.Column + 1);
                if (Board.ValidPosition(pos) && CanCapture(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }

                pos.DefinePosition(Position.Row - 1, Position.Column - 1);
                if (Board.ValidPosition(pos) && CanCapture(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }
            }
            else
            {
                pos.DefinePosition(Position.Row + 1, Position.Column);
                if (Board.ValidPosition(pos) && CanMove(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }

                pos.DefinePosition(Position.Row + 2, Position.Column);
                if (Board.ValidPosition(pos) && CanMove(pos) && NumberOfMoves == 0)
                {
                    mat[pos.Row, pos.Column] = true;
                }

                pos.DefinePosition(Position.Row + 1, Position.Column + 1);
                if (Board.ValidPosition(pos) && CanCapture(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }

                pos.DefinePosition(Position.Row + 1, Position.Column - 1);
                if (Board.ValidPosition(pos) && CanCapture(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }
            }

            return(mat);
        }