当前位置: 首页>>代码示例>>C#>>正文


C# GameState.PlayTurn方法代码示例

本文整理汇总了C#中Dominion.GameState.PlayTurn方法的典型用法代码示例。如果您正苦于以下问题:C# GameState.PlayTurn方法的具体用法?C# GameState.PlayTurn怎么用?C# GameState.PlayTurn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dominion.GameState的用法示例。


在下文中一共展示了GameState.PlayTurn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        /*
         *  This code answers the following question.   It's player 1's turn.   No provinces have been bought yet - but he's down
         *  scrying pools (lost the split 4/6) and has a more non actions in his deck than the opponent.   Opponenent can
         *  also double province on his turn.  If player1 starts a double province buy war, he will probably Not chain first and lose.
         *  So intead, though he can afford 2 provinces, opts for 1 province, 2 estates and 2 crossroads.
         *  This leaves the deck composition as described below, with scrying pool and festival pile already empty.
         *  There are remaining 6 estates ending, the plan is on the next turn to chain enough of the deck to buy all 6 estates
         *  and 3 pile out the game.   What is the probability of this happening?  (need to draw all 5 festivals and 2 additional coin)
         * */
        public static void Run()
        {
            var player1 = ScryingPoolAndCrossroads.Player();
            var player2 = Strategies.BigMoney.Player();

            var builder = new GameConfigBuilder();
            builder.CardSplit = StartingCardSplit.Random;

            builder.SetStartingDeckPerPlayer(
                new Dominion.CardCountPair[][]
            {
                new Dominion.CardCountPair[]        // Player1
                {
                    new Dominion.CardCountPair(Cards.Estate, 5),
                    new Dominion.CardCountPair(Cards.Province, 1),
                    new Dominion.CardCountPair(Cards.Festival, 5),
                    new Dominion.CardCountPair(Cards.Silver, 2),
                    new Dominion.CardCountPair(Cards.Copper, 2),
                    new Dominion.CardCountPair(Cards.CrossRoads, 3),
                    new Dominion.CardCountPair(Cards.ScryingPool, 4),
                    new Dominion.CardCountPair(Cards.WanderingMinstrel, 1),
                    new Dominion.CardCountPair(Cards.Remake, 1),
                },
                new Dominion.CardCountPair[]        // Player2
                {
                    new Dominion.CardCountPair(Cards.Estate, 3),
                    new Dominion.CardCountPair(Cards.Copper, 7),
                }
            });

            builder.SetKingdomCards(player1, player2);
            GameConfig gameConfig = builder.ToGameConfig();

            var playerActions = new PlayerAction[] { player1, player2 };

            int countWin = 0;
            int countGame = 1000;
            for (int i = 0; i < countGame; ++i)
            {
                using (var indentedTextOutput = TestOutput.GetGameLogWriterForIteration(playerActions, i))
                {
                    var gameLog = new HumanReadableGameLog(indentedTextOutput);
                    using (Game game = new Game(new Random(i), gameConfig, gameLog))
                    {
                        GameState gameState = new GameState(playerActions, new int[] { 0, 1 }, game);

                        PlayerState currentPlayer = gameState.players[0];

                        gameLog.BeginRound(currentPlayer);
                        gameState.PlayTurn(currentPlayer);
                        // 11 = 3 starting estates plus all 8 estates in the pile
                        if (currentPlayer.AllOwnedCards.CountOf(Cards.Estate) == 11)
                        {
                            countWin++;
                            System.Console.WriteLine("Won Game {0}", i);
                        }
                    }
                }
            }

            System.Console.WriteLine("{1}% win for {0}", player1.PlayerName, (double)countWin / countGame * 100);
        }
开发者ID:NathanTeeuwen,项目名称:Dominulator,代码行数:71,代码来源:OddsOfScryingPoolAndCrossroadsAllDraw.cs


注:本文中的Dominion.GameState.PlayTurn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。