Beispiel #1
0
        public override void FindFieldsToMove(ChessBoard board)
        {
            if (IsKilled)
            {
                return;
            }
            FieldsToMove.Clear();
            FieldStatus ownStatus = Color == Color.WHITE
                ? FieldStatus.OCCUPIED_WITH_WHITE
                : FieldStatus.OCCUPIED_WITH_BLACK;
            int  row;
            char column = '\0';

            for (int i = 0; i < 8; i++)
            {
                if (i < 2)
                {
                    row = CurrentField.Row + 2;
                }
                else if (i < 4)
                {
                    row = CurrentField.Row + 1;
                }
                else if (i < 6)
                {
                    row = CurrentField.Row - 1;
                }
                else
                {
                    row = CurrentField.Row - 2;
                }
                if (i == 2 || i == 4)
                {
                    column = (char)(CurrentField.Column - 2);
                }
                else if (i == 0 || i == 6)
                {
                    column = (char)(CurrentField.Column - 1);
                }
                else if (i == 1 || i == 7)
                {
                    column = (char)(CurrentField.Column + 1);
                }
                else if (i == 3 || i == 5)
                {
                    column = (char)(CurrentField.Column + 2);
                }
                if (row < 1 || row > 8 || column < 'A' || column > 'H')
                {
                    continue;
                }

                ChessField field = board.GetField(row, column);
                if (field.Status != ownStatus)
                {
                    FieldsToMove.Add(field);
                }
            }
        }
Beispiel #2
0
        public override void FindFieldsToMove(ChessBoard board)
        {
            if (IsKilled)
            {
                return;
            }
            FieldsToMove.Clear();
            FieldStatus ownStatus = Color == Color.WHITE
                ? FieldStatus.OCCUPIED_WITH_WHITE
                : FieldStatus.OCCUPIED_WITH_BLACK;

            FindFieldsUpwards(board, ownStatus);
            FindFieldsDownwards(board, ownStatus);
        }
Beispiel #3
0
        public override void FindFieldsToMove(ChessBoard board)
        {
            if (IsKilled)
            {
                return;
            }
            FieldsToMove.Clear();
            FieldStatus enemyStatus = Color == Color.WHITE
                ? FieldStatus.OCCUPIED_WITH_BLACK
                : FieldStatus.OCCUPIED_WITH_WHITE;
            int row = Color == Color.WHITE ? CurrentField.Row + 1 : CurrentField.Row - 1;

            if (row < 1 || row > 8)
            {
                return;
            }
            ChessField field = board.GetField(row, CurrentField.Column);

            if (field.Status == FieldStatus.EMPTY)
            {
                FieldsToMove.Add(field);
            }

            char column = (char)(CurrentField.Column - 1);

            field = board.GetField(row, column);
            if (field.Status == enemyStatus)
            {
                FieldsToMove.Add(field);
            }
            column = (char)(CurrentField.Column + 1);
            field  = board.GetField(row, column);
            if (field.Status == enemyStatus)
            {
                FieldsToMove.Add(field);
            }

            if (PreviousMoves.Count == 0)
            {
                row   = Color == Color.WHITE ? CurrentField.Row + 2 : CurrentField.Row - 2;
                field = board.GetField(row, CurrentField.Column);
                if (field.Status == FieldStatus.EMPTY)
                {
                    FieldsToMove.Add(field);
                }
            }
        }
Beispiel #4
0
        public override void FindFieldsToMove(ChessBoard board)
        {
            FieldsToMove.Clear();
            FieldStatus ownStatus = Color == Color.WHITE
                ? FieldStatus.OCCUPIED_WITH_WHITE
                : FieldStatus.OCCUPIED_WITH_BLACK;

            List <int> potentialRows = new List <int>();

            if (CurrentField.Row != 1)
            {
                potentialRows.Add(CurrentField.Row - 1);
            }
            potentialRows.Add(CurrentField.Row);
            if (CurrentField.Row != 8)
            {
                potentialRows.Add(CurrentField.Row + 1);
            }
            List <char> potentialColumns = new List <char>();

            if (CurrentField.Column != 'A')
            {
                potentialColumns.Add((char)((int)CurrentField.Column - 1));
            }
            potentialColumns.Add(CurrentField.Column);
            if (CurrentField.Column != 'H')
            {
                potentialColumns.Add((char)((int)CurrentField.Column + 1));
            }

            foreach (int row in potentialRows)
            {
                foreach (char column in potentialColumns)
                {
                    ChessField field = board.GetField(row, column);
                    if (field.Status != ownStatus)
                    {
                        FieldsToMove.Add(field);
                    }
                }
            }
        }