GetSupplyPiles() public method

public GetSupplyPiles ( int numberOfPlayers, Random random ) : Dominion.PileOfCards[]
numberOfPlayers int
random System.Random
return Dominion.PileOfCards[]
Beispiel #1
0
        public GameState(
            IPlayerAction[] playerActions,
            int[] playerPositions,
            Game game,
            IEnumerable <CardCountPair>[] startingDeckPerPlayer = null)
        {
            this.game = game;
            GameConfig gameConfig = game.GameConfig;

            int playerCount = playerActions.Length;

            this.supplyPiles    = gameConfig.GetSupplyPiles(playerCount, game.random);
            this.nonSupplyPiles = gameConfig.GetNonSupplyPiles();

            this.mapCardToPile = new MapOfCardsForGameSubset <PileOfCards>(this.CardGameSubset);
            this.BuildMapOfCardToPile();

            this.players = new PlayerCircle(playerCount, playerActions, playerPositions, game);

            this.hasPileEverBeenGained = new MapPileOfCards <bool>(this.supplyPiles);
            this.pileEmbargoTokenCount = new MapPileOfCards <int>(this.supplyPiles);
            this.trash = new BagOfCards(this.CardGameSubset);

            this.GainStartingCards(gameConfig);

            this.players.AllPlayersDrawInitialCards(gameConfig);

            foreach (PileOfCards cardPile in this.supplyPiles)
            {
                cardPile.ProtoTypeCard.DoSpecializedSetupIfInSupply(this);
            }
        }
        public static void FindBestStrategyForGame(GameConfig gameConfig)
        {
            var initialDescription = new PickByPriorityDescription(new CardAcceptanceDescription[]
            {
                new CardAcceptanceDescription( Cards.Province, new MatchDescription[] { new MatchDescription( null, CountSource.None, Comparison.None, 0)}),
                new CardAcceptanceDescription( Cards.Gold, new MatchDescription[] { new MatchDescription( null, CountSource.None, Comparison.None, 0)}),
                new CardAcceptanceDescription( Cards.Silver, new MatchDescription[] { new MatchDescription( null, CountSource.None, Comparison.None, 0)})
            });

            Random random = new Random();

            Card[] supplyCards = gameConfig.GetSupplyPiles(2, random).Select(pile => pile.ProtoTypeCard).ToArray();

            var initialPopulation = Enumerable.Range(0, 10).Select(index => initialDescription).ToArray();
            var algorithm = new GeneticAlgorithm<PickByPriorityDescription, MutatePickByPriorityDescription, CompareStrategies>(
                initialPopulation,
                new MutatePickByPriorityDescription(random, supplyCards),
                new CompareStrategies(),
                new Random());

            for (int i = 0; i < 1000; ++i)
            {
                System.Console.WriteLine("Generation {0}", i);
                System.Console.WriteLine("==============", i);
                for (int j = 0; j < 10; ++j)
                {
                    algorithm.currentMembers[j].Write(System.Console.Out);
                    System.Console.WriteLine();
                }

                algorithm.RunOneGeneration();

                System.Console.WriteLine();
            }
        }
Beispiel #3
0
        public GameState(             
            IGameLog gameLog,
            IPlayerAction[] players,
            GameConfig gameConfig,
            Random random,
            IEnumerable<CardCountPair>[] startingDeckPerPlayer = null)
        {
            int playerCount = players.Length;
            this.gameLog = gameLog;
            this.cardGameSubset = gameConfig.cardGameSubset;
            this.supplyPiles = gameConfig.GetSupplyPiles(playerCount, random);
            this.nonSupplyPiles = gameConfig.GetNonSupplyPiles();

            this.mapCardToPile = new MapOfCards<PileOfCards>(this.cardGameSubset);
            this.BuildMapOfCardToPile();

            this.players = new PlayerCircle(playerCount, players, this.gameLog, random, this.cardGameSubset);

            this.hasPileEverBeenGained = new MapPileOfCardsToProperty<bool>(this.supplyPiles);
            this.pileEmbargoTokenCount = new MapPileOfCardsToProperty<int>(this.supplyPiles);
            this.trash = new BagOfCards(this.cardGameSubset);

            this.GainStartingCards(gameConfig);

            this.players.AllPlayersDrawInitialCards(gameConfig);

            foreach (PileOfCards cardPile in this.supplyPiles)
            {
                cardPile.ProtoTypeCard.DoSpecializedSetupIfInSupply(this);
            }
        }
Beispiel #4
0
        public GameState(
            IPlayerAction[] playerActions,
            int[] playerPositions,
            Game game)
        {
            if (playerActions.Length != playerPositions.Length)
            {
                throw new Exception();
            }

            this.game = game;
            GameConfig gameConfig = game.GameConfig;

            this.emptyCardCollection = new CollectionCards(this.CardGameSubset, null);

            int playerCount = playerActions.Length;

            this.supplyPiles    = gameConfig.GetSupplyPiles(playerCount, game.random);
            this.nonSupplyPiles = gameConfig.GetNonSupplyPiles(playerCount);

            this.mapCardToPile = new MapOfCardsForGameSubset <PileOfCards>(this.CardGameSubset);
            this.BuildMapOfCardToPile();

            this.players = new PlayerCircle(playerCount, playerActions, playerPositions, game);

            this.hasPileEverBeenGained = new MapPileOfCards <bool>(this.supplyPiles);
            this.pileEmbargoTokenCount = new MapPileOfCards <int>(this.supplyPiles);
            this.trash = new BagOfCards(this.CardGameSubset);

            this.cardContextStack = new CardContextStack();

            this.GainStartingCards(gameConfig);

            foreach (PileOfCards cardPile in this.supplyPiles)
            {
                cardPile.ProtoTypeCard.DoSpecializedSetupIfInSupply(this);
            }

            this.players.AllPlayersDrawInitialCards(gameConfig, this);
        }