예제 #1
0
        public override bool[,] PossiblesMoviments()
        {
            bool[,] mat = new bool[Board.Rows, Board.Columns];

            Position pos = new Position(0, 0);

            //up
            pos.SetPosition(Position.Row - 1, Position.Column);

            while (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;

                if (Board.GetPiece(pos) != null && Board.GetPiece(pos).Color != Color)
                {
                    break;
                }

                pos.Row = pos.Row - 1;
            }

            //down
            pos.SetPosition(Position.Row + 1, Position.Column);
            while (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;

                if (Board.GetPiece(pos) != null && Board.GetPiece(pos).Color != Color)
                {
                    break;
                }

                pos.Row = pos.Row + 1;
            }

            //right
            pos.SetPosition(Position.Row, Position.Column + 1);
            while (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;

                if (Board.GetPiece(pos) != null && Board.GetPiece(pos).Color != Color)
                {
                    break;
                }

                pos.Column = pos.Column + 1;
            }

            //left
            pos.SetPosition(Position.Row, Position.Column - 1);
            while (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;

                if (Board.GetPiece(pos) != null && Board.GetPiece(pos).Color != Color)
                {
                    break;
                }

                pos.Column = pos.Column - 1;
            }

            return(mat);
        }
예제 #2
0
        public override bool[,] PossiblesMoviments()
        {
            bool[,] mat = new bool[Board.Rows, Board.Columns];

            Position pos = new Position(0, 0);

            //up
            pos.SetPosition(Position.Row - 1, Position.Column);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;
            }

            //up right
            pos.SetPosition(Position.Row - 1, Position.Column + 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;
            }

            //up left
            pos.SetPosition(Position.Row - 1, Position.Column - 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;
            }

            //left
            pos.SetPosition(Position.Row, Position.Column - 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;
            }

            //right
            pos.SetPosition(Position.Row, Position.Column + 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;
            }

            //down
            pos.SetPosition(Position.Row + 1, Position.Column);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;
            }

            //down right
            pos.SetPosition(Position.Row + 1, Position.Column + 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;
            }

            //down left
            pos.SetPosition(Position.Row + 1, Position.Column - 1);
            if (Board.ValidPosition(pos) && CanMove(pos))
            {
                mat[pos.Row, pos.Column] = true;
            }

            // #SpecialMoviment: Small Rock
            if (AmtMoviments == 0 && !Match.Check)
            {
                Position posTower1 = new Position(Position.Row, Position.Column + 3);
                if (TestTowerToRock(posTower1))
                {
                    Position p1 = new Position(Position.Row, Position.Column + 1);
                    Position p2 = new Position(Position.Row, Position.Column + 2);
                    if (Board.GetPiece(p1) == null && Board.GetPiece(p2) == null)
                    {
                        mat[Position.Row, Position.Column + 2] = true;
                    }
                }
            }

            // #SpecialMoviment: Large Rock
            if (AmtMoviments == 0 && !Match.Check)
            {
                Position posTower2 = new Position(Position.Row, Position.Column - 4);
                if (TestTowerToRock(posTower2))
                {
                    Position p1 = new Position(Position.Row, Position.Column - 1);
                    Position p2 = new Position(Position.Row, Position.Column - 2);
                    Position p3 = new Position(Position.Row, Position.Column - 3);
                    if (Board.GetPiece(p1) == null && Board.GetPiece(p2) == null && Board.GetPiece(p3) == null)
                    {
                        mat[Position.Row, Position.Column - 2] = true;
                    }
                }
            }
            return(mat);
        }
예제 #3
0
        public override bool[,] PossiblesMoviments()
        {
            bool[,] mat = new bool[Board.Rows, Board.Columns];

            Position pos = new Position(0, 0);

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

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

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


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

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

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

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


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

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


            return(mat);
        }
예제 #4
0
        public override bool[,] PossiblesMoviments()
        {
            bool[,] mat = new bool[Board.Rows, Board.Columns];

            Position pos = new Position(0, 0);

            if (Color == Color.White)
            {
                pos.SetPosition(Position.Row - 1, Position.Column);
                if (Board.ValidPosition(pos) && FreePosition(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }
                pos.SetPosition(Position.Row - 2, Position.Column);
                if (Board.ValidPosition(pos) && FreePosition(pos) && AmtMoviments == 0)
                {
                    mat[pos.Row, pos.Column] = true;
                }
                pos.SetPosition(Position.Row - 1, Position.Column - 1);
                if (Board.ValidPosition(pos) && ThereIsAdversary(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }
                pos.SetPosition(Position.Row - 1, Position.Column + 1);
                if (Board.ValidPosition(pos) && ThereIsAdversary(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }

                //#special moviment
                if (Position.Row == 3)
                {
                    Position left = new Position(Position.Row, Position.Column - 1);

                    if (Board.ValidPosition(left) && ThereIsAdversary(left) && Board.GetPiece(left) == Match.CanPassant)
                    {
                        mat[left.Row - 1, left.Column] = true;
                    }

                    Position right = new Position(Position.Row, Position.Column + 1);

                    if (Board.ValidPosition(right) && ThereIsAdversary(right) && Board.GetPiece(right) == Match.CanPassant)
                    {
                        mat[right.Row - 1, right.Column] = true;
                    }
                }
            }
            else
            {
                pos.SetPosition(Position.Row + 1, Position.Column);
                if (Board.ValidPosition(pos) && FreePosition(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }
                pos.SetPosition(Position.Row + 2, Position.Column);
                if (Board.ValidPosition(pos) && FreePosition(pos) && AmtMoviments == 0)
                {
                    mat[pos.Row, pos.Column] = true;
                }
                pos.SetPosition(Position.Row + 1, Position.Column - 1);
                if (Board.ValidPosition(pos) && ThereIsAdversary(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }
                pos.SetPosition(Position.Row + 1, Position.Column + 1);
                if (Board.ValidPosition(pos) && ThereIsAdversary(pos))
                {
                    mat[pos.Row, pos.Column] = true;
                }

                //#special moviment
                if (Position.Row == 4)
                {
                    Position left = new Position(Position.Row, Position.Column - 1);

                    if (Board.ValidPosition(left) && ThereIsAdversary(left) && Board.GetPiece(left) == Match.CanPassant)
                    {
                        mat[left.Row + 1, left.Column] = true;
                    }

                    Position right = new Position(Position.Row, Position.Column + 1);

                    if (Board.ValidPosition(right) && ThereIsAdversary(right) && Board.GetPiece(right) == Match.CanPassant)
                    {
                        mat[right.Row + 1, right.Column] = true;
                    }
                }
            }


            return(mat);
        }