Exemplo n.º 1
0
        static List <DataStructure.Point> FindMovesBlack(DataStructure.Point possition, int[,] boardMatrix)
        {
            List <DataStructure.Point> possiblePossitions = new List <DataStructure.Point>();

            DataStructure.Point p;
            for (int i = possition.i - 1; i > -1; i--)
            {
                p = new DataStructure.Point(i, possition.j);
                if (Validation.IsEmpty(p, boardMatrix))
                {
                    possiblePossitions.Add(p);
                }
                else
                {
                    if (Validation.IsOpponent(p, boardMatrix))
                    {
                        possiblePossitions.Add(p);
                    }
                    break;
                }
            }
            for (int i = possition.i + 1; i < 8; i++)
            {
                p = new DataStructure.Point(i, possition.j);
                if (Validation.IsEmpty(p, boardMatrix))
                {
                    possiblePossitions.Add(p);
                }
                else
                {
                    if (Validation.IsOpponent(p, boardMatrix))
                    {
                        possiblePossitions.Add(p);
                    }
                    break;
                }
            }
            for (int j = possition.j - 1; j > -1; j--)
            {
                p = new DataStructure.Point(possition.i, j);
                if (Validation.IsEmpty(p, boardMatrix))
                {
                    possiblePossitions.Add(p);
                }
                else
                {
                    if (Validation.IsOpponent(p, boardMatrix))
                    {
                        possiblePossitions.Add(p);
                    }
                    break;
                }
            }
            for (int j = possition.j + 1; j < 8; j++)
            {
                p = new DataStructure.Point(possition.i, j);
                if (Validation.IsEmpty(p, boardMatrix))
                {
                    possiblePossitions.Add(p);
                }
                else
                {
                    if (Validation.IsOpponent(p, boardMatrix))
                    {
                        possiblePossitions.Add(p);
                    }
                    break;
                }
            }

            return(possiblePossitions);
        }
Exemplo n.º 2
0
        static List <DataStructure.Point> FindMovesWhite(DataStructure.Point possition, int[,] boardMatrix)
        {
            List <DataStructure.Point> possiblePossitions = new List <DataStructure.Point>();

            DataStructure.Point p;

            try
            {
                int i = possition.i - 1;
                int j = possition.j - 1;
                while (i > -1 && j > -1)
                {
                    p = new DataStructure.Point(i, j);
                    if (Validation.IsEmpty(p, boardMatrix))
                    {
                        possiblePossitions.Add(p);
                    }
                    else
                    {
                        if (Validation.IsOpponent(p, boardMatrix))
                        {
                            possiblePossitions.Add(p);
                        }
                        break;
                    }
                    i--;
                    j--;
                }
                i = possition.i - 1;
                j = possition.j + 1;
                while (i > -1 && j < 8)
                {
                    p = new DataStructure.Point(i, j);
                    if (Validation.IsEmpty(p, boardMatrix))
                    {
                        possiblePossitions.Add(p);
                    }
                    else
                    {
                        if (Validation.IsOpponent(p, boardMatrix))
                        {
                            possiblePossitions.Add(p);
                        }
                        break;
                    }
                    i--;
                    j++;
                }
                i = possition.i + 1;
                j = possition.j - 1;
                while (i < 8 && j > -1)
                {
                    p = new DataStructure.Point(i, j);
                    if (Validation.IsEmpty(p, boardMatrix))
                    {
                        possiblePossitions.Add(p);
                    }
                    else
                    {
                        if (Validation.IsOpponent(p, boardMatrix))
                        {
                            possiblePossitions.Add(p);
                        }
                        break;
                    }
                    i++;
                    j--;
                }
                i = possition.i + 1;
                j = possition.j + 1;
                while (i < 8 && j < 8)
                {
                    p = new DataStructure.Point(i, j);
                    if (Validation.IsEmpty(p, boardMatrix))
                    {
                        possiblePossitions.Add(p);
                    }
                    else
                    {
                        if (Validation.IsOpponent(p, boardMatrix))
                        {
                            possiblePossitions.Add(p);
                        }
                        break;
                    }
                    i++;
                    j++;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return(possiblePossitions);
        }