예제 #1
0
        public override bool[,] possibleMove()
        {
            bool[,] mat = new bool[gameBoard.Lines, gameBoard.Columns];

            Position pos = new Position(0, 0);

            // right + above
            pos.definePosition(position.Line - 1, position.Column + 1);
            while (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
                if (gameBoard.piece(pos) != null && gameBoard.piece(pos).color != color)
                {
                    break;
                }
                pos.Line--;
                pos.Column++;
            }

            //right + below
            pos.definePosition(position.Line + 1, position.Column + 1);
            while (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
                if (gameBoard.piece(pos) != null && gameBoard.piece(pos).color != color)
                {
                    break;
                }
                pos.Line++;
                pos.Column++;
            }

            //left + below
            pos.definePosition(position.Line + 1, position.Column - 1);
            while (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
                if (gameBoard.piece(pos) != null && gameBoard.piece(pos).color != color)
                {
                    break;
                }
                pos.Line++;
                pos.Column--;
            }

            //left + above
            pos.definePosition(position.Line - 1, position.Column - 1);
            while (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
                if (gameBoard.piece(pos) != null && gameBoard.piece(pos).color != color)
                {
                    break;
                }
                pos.Line--;
                pos.Column--;
            }

            return(mat);
        }
예제 #2
0
        public override bool[,] possibleMove()
        {
            bool[,] mat = new bool[gameBoard.Lines, gameBoard.Columns];

            Position pos = new Position(0, 0);

            //above
            pos.definePosition(position.Line - 1, position.Column);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // right + above
            pos.definePosition(position.Line - 1, position.Column + 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // right
            pos.definePosition(position.Line, position.Column + 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // right + below
            pos.definePosition(position.Line + 1, position.Column + 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // below
            pos.definePosition(position.Line + 1, position.Column);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // left + above
            pos.definePosition(position.Line - 1, position.Column - 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // left
            pos.definePosition(position.Line, position.Column - 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // left + below
            pos.definePosition(position.Line + 1, position.Column - 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            // #specialmove King's Indian Defense
            if (MoveCount == 0 && !game.Check)
            {
                // Short KID special move
                Position posRook1 = new Position(position.Line, position.Column + 3);

                if (testRookForKID(posRook1))
                {
                    Position p1 = new Position(position.Line, position.Column + 1);
                    Position p2 = new Position(position.Line, position.Column + 2);
                    if (gameBoard.piece(p1) == null && gameBoard.piece(p2) == null)
                    {
                        mat[position.Line, position.Column + 2] = true;
                    }
                }

                // Long KID special move
                Position posRook2 = new Position(position.Line, position.Column - 4);

                if (testRookForKID(posRook2))
                {
                    Position p1 = new Position(position.Line, position.Column - 1);
                    Position p2 = new Position(position.Line, position.Column - 2);
                    Position p3 = new Position(position.Line, position.Column - 3);
                    if (gameBoard.piece(p1) == null && gameBoard.piece(p2) == null && gameBoard.piece(p3) == null)
                    {
                        mat[position.Line, position.Column - 2] = true;
                    }
                }
            }

            return(mat);
        }
예제 #3
0
        public override bool[,] possibleMove()
        {
            bool[,] mat = new bool[gameBoard.Lines, gameBoard.Columns];

            Position pos = new Position(0, 0);

            if (color == Color.White) // Whites
            {
                //above
                pos.definePosition(position.Line - 1, position.Column);
                if (gameBoard.testValidPosition(pos) && canMove(pos))
                {
                    mat[pos.Line, pos.Column] = true;
                }

                // first move
                pos.definePosition(position.Line - 2, position.Column);
                if (gameBoard.testValidPosition(pos) && canMove(pos) && MoveCount == 0)
                {
                    mat[pos.Line, pos.Column] = true;
                }

                // right + above
                pos.definePosition(position.Line - 1, position.Column + 1);
                if (gameBoard.testValidPosition(pos) && canEat(pos))
                {
                    mat[pos.Line, pos.Column] = true;
                }

                // left + above
                pos.definePosition(position.Line - 1, position.Column - 1);
                if (gameBoard.testValidPosition(pos) && canEat(pos))
                {
                    mat[pos.Line, pos.Column] = true;
                }

                // #specialmove En Passant
                if (position.Line == 3)
                {
                    Position left  = new Position(position.Line, position.Column - 1);
                    Position right = new Position(position.Line, position.Column + 1);
                    if (gameBoard.testValidPosition(left) && canEat(left) && gameBoard.piece(left) == game.enPassantDanger)
                    {
                        mat[left.Line - 1, left.Column] = true;
                    }
                    if (gameBoard.testValidPosition(right) && canEat(right) && gameBoard.piece(right) == game.enPassantDanger)
                    {
                        mat[right.Line - 1, right.Column] = true;
                    }
                }
            }
            else // Blacks
            {
                //below
                pos.definePosition(position.Line + 1, position.Column);
                if (gameBoard.testValidPosition(pos) && canMove(pos))
                {
                    mat[pos.Line, pos.Column] = true;
                }

                // first move
                pos.definePosition(position.Line + 2, position.Column);
                if (gameBoard.testValidPosition(pos) && canMove(pos) && MoveCount == 0)
                {
                    mat[pos.Line, pos.Column] = true;
                }

                // right + below
                pos.definePosition(position.Line + 1, position.Column + 1);
                if (gameBoard.testValidPosition(pos) && canEat(pos))
                {
                    mat[pos.Line, pos.Column] = true;
                }

                // left + below
                pos.definePosition(position.Line + 1, position.Column - 1);
                if (gameBoard.testValidPosition(pos) && canEat(pos))
                {
                    mat[pos.Line, pos.Column] = true;
                }

                // #specialmove En Passant
                if (position.Line == 4)
                {
                    Position left  = new Position(position.Line, position.Column - 1);
                    Position right = new Position(position.Line, position.Column + 1);
                    if (gameBoard.testValidPosition(left) && canEat(left) && gameBoard.piece(left) == game.enPassantDanger)
                    {
                        mat[left.Line + 1, left.Column] = true;
                    }
                    if (gameBoard.testValidPosition(right) && canEat(right) && gameBoard.piece(right) == game.enPassantDanger)
                    {
                        mat[right.Line + 1, right.Column] = true;
                    }
                }
            }


            return(mat);
        }
예제 #4
0
        public override bool[,] possibleMove()
        {
            bool[,] mat = new bool[gameBoard.Lines, gameBoard.Columns];

            Position pos = new Position(0, 0);

            //above, right
            pos.definePosition(position.Line - 2, position.Column + 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            //above, left
            pos.definePosition(position.Line - 2, position.Column - 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            //right, above
            pos.definePosition(position.Line - 1, position.Column + 2);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            //right, below
            pos.definePosition(position.Line + 1, position.Column + 2);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            //below, right
            pos.definePosition(position.Line + 2, position.Column + 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            //below, left
            pos.definePosition(position.Line + 2, position.Column - 1);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            //left, above
            pos.definePosition(position.Line - 1, position.Column - 2);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            //left, below
            pos.definePosition(position.Line + 1, position.Column - 2);
            if (gameBoard.testValidPosition(pos) && canMove(pos))
            {
                mat[pos.Line, pos.Column] = true;
            }

            return(mat);
        }