Exemple #1
0
        /// <summary>
        /// Generates the possible moves of the current board.
        /// </summary>
        private void GenerateMoves()
        {
            // clear the list
            possibleMoves.Clear();

            // loop the starting squares through all the squares
            for (int fromIndex = 0; fromIndex < Board.SquareNo; fromIndex++)
            {
                // if it's a side to move piece on this square
                if (currentBoard.IsSideToMovePiece(fromIndex))
                {
                    // loop the ending squares through all the squares
                    for (int toIndex = 0; toIndex < Board.SquareNo; toIndex++)
                    {
                        // try to generate the move
                        Move move = currentBoard[fromIndex].GenerateMove(currentBoard, fromIndex, toIndex);
                        if (move != null)
                        {
                            possibleMoves.Add(move);
                        }
                    }
                }
            }
        }