コード例 #1
0
        public static List <Board> getBiomeConfigurationsRecursive(Stack <HexagonalCoordinate> coordinates, TileCounts tileCounts, Board currentState)
        {
            if (coordinates.Count == 0)
            {
                return(new List <Board> {
                    currentState
                });
            }

            List <Board>        toReturn       = new List <Board>();
            HexagonalCoordinate nextCoordinate = coordinates.Pop();

            if (tileCounts.clay > 0)
            {
                Board?nextState = getNextValidState(Tile.CLAY, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(new Stack <HexagonalCoordinate>(coordinates), tileCounts.removeClay(), nextState));
                }
            }
            if (tileCounts.wood > 0)
            {
                Board?nextState = getNextValidState(Tile.WOOD, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(new Stack <HexagonalCoordinate>(coordinates), tileCounts.removeWood(), nextState));
                }
            }
            if (tileCounts.wheat > 0)
            {
                Board?nextState = getNextValidState(Tile.WHEAT, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(new Stack <HexagonalCoordinate>(coordinates), tileCounts.removeWheat(), nextState));
                }
            }
            if (tileCounts.sheep > 0)
            {
                Board?nextState = getNextValidState(Tile.SHEEP, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(new Stack <HexagonalCoordinate>(coordinates), tileCounts.removeSheep(), nextState));
                }
            }
            if (tileCounts.stone > 0)
            {
                Board?nextState = getNextValidState(Tile.STONE, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(new Stack <HexagonalCoordinate>(coordinates), tileCounts.removeStone(), nextState));
                }
            }
            if (tileCounts.desert > 0)
            {
                Board?nextState = getNextValidState(Tile.DESERT, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(new Stack <HexagonalCoordinate>(coordinates), tileCounts.removeDesert(), nextState));
                }
            }

            return(toReturn);
        }
コード例 #2
0
        public static List <Board> getBiomeConfigurationsRecursive(int currentIndex, int maxIndex, TileCounts tileCounts, Board currentState)
        {
            if (currentIndex == maxIndex)
            {
                return(new List <Board> {
                    currentState
                });
            }

            List <Board>        toReturn       = new List <Board>();
            HexagonalCoordinate nextCoordinate = Board.indexToCoordinate(currentIndex);

            if (tileCounts.clay > 0)
            {
                Board?nextState = getNextValidState(Tile.CLAY, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(currentIndex + 1, maxIndex, tileCounts.removeClay(), nextState));
                }
            }
            if (tileCounts.wood > 0)
            {
                Board?nextState = getNextValidState(Tile.WOOD, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(currentIndex + 1, maxIndex, tileCounts.removeWood(), nextState));
                }
            }
            if (tileCounts.wheat > 0)
            {
                Board?nextState = getNextValidState(Tile.WHEAT, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(currentIndex + 1, maxIndex, tileCounts.removeWheat(), nextState));
                }
            }
            if (tileCounts.sheep > 0)
            {
                Board?nextState = getNextValidState(Tile.SHEEP, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(currentIndex + 1, maxIndex, tileCounts.removeSheep(), nextState));
                }
            }
            if (tileCounts.stone > 0)
            {
                Board?nextState = getNextValidState(Tile.STONE, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(currentIndex + 1, maxIndex, tileCounts.removeStone(), nextState));
                }
            }
            if (tileCounts.desert > 0)
            {
                Board?nextState = getNextValidState(Tile.DESERT, nextCoordinate, currentState);
                if (nextState != null)
                {
                    toReturn.AddRange(getBiomeConfigurationsRecursive(currentIndex + 1, maxIndex, tileCounts.removeDesert(), nextState));
                }
            }

            return(toReturn);
        }