コード例 #1
0
        private void GetAvailableMovesInInterval(Board.Board board, List <KeyValuePair <int, int> > availableMoves, int rowInterval, int colInterval)
        {
            int row = this.CurrentLocation_x;
            int col = this.CurrentLocation_y;

            for (int i = 0; i <= 7; i++)
            {
                row += rowInterval;
                col += colInterval;
                if (board.IsInRange(row, col))
                {
                    var piece = board.Instance[row, col];
                    if (piece == null)
                    {
                        availableMoves.Add(new KeyValuePair <int, int>(row, col));
                    }
                    else
                    {
                        if (piece.Color != this.Color)
                        {
                            availableMoves.Add(new KeyValuePair <int, int>(row, col));
                        }
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
        }
コード例 #2
0
        private void GetAvailableMove(Board.Board board, List <KeyValuePair <int, int> > availableMoves, int rowInterval, int colInterval)
        {
            var row    = this.CurrentLocation_x + rowInterval;
            var column = this.CurrentLocation_y + colInterval;

            if (board.IsInRange(row, column))
            {
                var piece = board.Instance[row, column];
                if (piece == null || (piece != null && piece.Color != Color))
                {
                    availableMoves.Add(new KeyValuePair <int, int>(row, column));
                }
            }
        }
コード例 #3
0
        private void GetAvailableMove(Board.Board board, List <KeyValuePair <int, int> > availableMoves, int rowInterval, int colInterval)
        {
            var row    = this.CurrentLocation_x + rowInterval;
            var column = this.CurrentLocation_y + colInterval;

            if (board.IsInRange(row, column))
            {
                var piece = board.Instance[row, column];
                if (piece == null || (piece != null && piece.Color != this.Color))
                {
                    var kingCopy = (King)board.DeepClone(this);
                    var simBoard = (Board.Board)board.DeepClone(board);
                    simBoard.MovePiece(kingCopy, row, column);
                    if (!kingCopy.IsInCheck(simBoard))
                    {
                        availableMoves.Add(new KeyValuePair <int, int>(row, column));
                    }
                }
            }
        }
コード例 #4
0
        private void GetCheckPathInInterval(Board.Board board, List <KeyValuePair <int, int> > checkPath, int rowInterval, int colInterval)
        {
            int row = this.CurrentLocation_x;
            int col = this.CurrentLocation_y;

            for (int i = 0; i <= 7; i++)
            {
                row += rowInterval;
                col += colInterval;
                if (board.IsInRange(row, col))
                {
                    var piece = board.Instance[row, col];
                    if (piece == null)
                    {
                        checkPath.Add(new KeyValuePair <int, int>(row, col));
                    }
                    else
                    {
                        if (piece.Color != this.Color)
                        {
                            checkPath.Add(new KeyValuePair <int, int>(row, col));
                            if (piece.Type == PieceTypeEnum.King)
                            {
                                return;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            checkPath = new List <KeyValuePair <int, int> >();
        }