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


C# Player.Reset方法代码示例

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


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

示例1: foreach

        void INotificationService.Die(Player player)
        {
            foreach (var clientId in player.ClientIds)
            {
                Clients[clientId].receive(new PlayerPacket(new PlayerMessages("You have died...", MessageType.Important)));
                Groups.Remove(clientId, player.RoomReference.Id).Wait();
            }

            // Let everybody know about the death.
            Clients.receive(new PlayerPacket(new PlayerMessages(String.Format("{0} has died.", player.Name), MessageType.Notification)));

            _world.Teleport(player, player.RoomReference);
            player.Reset();

            // The rebirth!
            Clients[player.RoomReference.Id].receive(
                new PlayerPacket(new PlayerMessages(String.Format("{0} is birthed in an orange light!", player.Name),
                                                    MessageType.Important)));

            // Join room 1
            foreach (var clientId in player.ClientIds)
                Groups.Add(clientId, player.RoomReference.Id).Wait();

            // TODO:  Temporary.  Add a javascript .death function to call.
            var cmd = new CommandManager(Context.ConnectionId, player, _world, this);
            cmd.TryHandleCommand("look");
        }
开发者ID:jrmitch120,项目名称:Legend,代码行数:27,代码来源:LegendHub.cs

示例2: TestWhenCallingGetWaterBalloonMoveAgainstAnOpponentWithDynamite_ThenWaterBalloonIsReturned

 public void TestWhenCallingGetWaterBalloonMoveAgainstAnOpponentWithDynamite_ThenWaterBalloonIsReturned()
 {
     Player player = new Player("Opponent", new MyBot());
     player.Reset(GameRules.Default);
     Move expected = Moves.WaterBalloon;
     Move actual = MyBotExtensions.GetWaterBalloonMove(player);
     Assert.AreEqual(expected, actual, "There is dynamite to defend against.");
 }
开发者ID:artlucia,项目名称:RockMeAzuredeus,代码行数:8,代码来源:MyBotExtensionsTest.cs

示例3: MakeMoveTest

        public void MakeMoveTest()
        {
            MyBot target = new MyBot();
            Player testPlayer = new Player("Test", target);
            testPlayer.Reset(GameRules.Default);

            IPlayer opponent = new Player("Opponent", new MyBot());
            Move actual = target.MakeMove(testPlayer, opponent, GameRules.Default);
            Assert.IsNotNull(actual, "This test expected a move to be made.");
        }
开发者ID:artlucia,项目名称:RockMeAzuredeus,代码行数:10,代码来源:MyBotTest.cs

示例4: TestWhenAnalysisHasNoHistory_ThenConfidenceIsVeryUnconfident

        public void TestWhenAnalysisHasNoHistory_ThenConfidenceIsVeryUnconfident()
        {
            var history = new MoveHistory_Accessor();
            var target = new MoveAnalyzer_Accessor(history);
            Player you = new Player("Test", new MyBot());
            you.Reset(GameRules.Default);

            target.Analyze(you);
            Confidence expected = Confidence.VeryUnconfident;
            Confidence actual = target.CurrentConfidence;
            Assert.AreEqual(expected, actual, "Odd that there is any confidence when there is no history.");
        }
开发者ID:artlucia,项目名称:RockMeAzuredeus,代码行数:12,代码来源:MoveAnalyzerTest.cs

示例5: TestWhenAnalysisEncountersARepeatedMove_ThenConfidenceIsVeryConfidentAndBestGuessIsDetermined

        public void TestWhenAnalysisEncountersARepeatedMove_ThenConfidenceIsVeryConfidentAndBestGuessIsDetermined()
        {
            var history = new MoveHistory_Accessor();
            var target = new MoveAnalyzer_Accessor(history);
            Player you = new Player("Test", new MyBot());
            you.Reset(GameRules.Default);

            history.OpponentMoveHistory.Add(Moves.Dynamite);
            history.OpponentMoveHistory.Add(Moves.Dynamite);
            history.OpponentMoveHistory.Add(Moves.Dynamite);

            target.Analyze(you);
            Confidence expected = Confidence.VeryConfident;
            Confidence actual = target.CurrentConfidence;
            Assert.AreEqual(expected, actual, "Confidence after the DDD pattern is not as expected.");
            Move expectedMove = Moves.WaterBalloon;
            Move actualMove = target.BestGuess;
            Assert.AreEqual(expectedMove, actualMove, "Best guess after the DDD pattern is not as expected.");
        }
开发者ID:artlucia,项目名称:RockMeAzuredeus,代码行数:19,代码来源:MoveAnalyzerTest.cs

示例6: Play

    public GameResults Play(Player player1, Player player2)
    {
      var log = new GameLog(player1, player2);
      player1.Reset(_rules);
      player2.Reset(_rules);

      var winDeterminer = new WinDeterminer();
      int pointValue = 1;
      int gameNumber = 0;

      while (player1.Points < _rules.PointsToWin && player2.Points < _rules.PointsToWin && gameNumber < _rules.MaximumGames)
      {
        var move1 = player1.GetMoveToMake(player2, _rules, log);
        var move2 = player2.GetMoveToMake(player1, _rules, log);

        var winner = winDeterminer.DetermineWinner(move1, move2);

        player1.SetLastMove(move1);
        player2.SetLastMove(move2);
        log.AfterMove(player1, player2);

        if (winner == null)
        {
          ++pointValue;
        }
        else
        {
          winner.AwardPoints(pointValue);
          pointValue = 1;
        }

        gameNumber++;
      }

      log.EndMatch();

      System.Diagnostics.Debug.WriteLine(player1.Bot + ": " + player1.TotalTimeDeciding + " " + player1.NumberOfDecisions + " " + (player1.TotalTimeDeciding.TotalMilliseconds/(double)player1.NumberOfDecisions));
      System.Diagnostics.Debug.WriteLine(player1.Bot + ": " + player2.TotalTimeDeciding + " " + player2.NumberOfDecisions + " " + (player2.TotalTimeDeciding.TotalMilliseconds/(double)player2.NumberOfDecisions));

      return new GameResults(player1, player2, log.GetLog());
    }
开发者ID:aaronjensen,项目名称:compete.rock_paper_scissors_pro,代码行数:41,代码来源:Game.cs

示例7: TestWhenReturningARandomDynamiteMove_ThenDynamiteIsReturnedSometimes

        public void TestWhenReturningARandomDynamiteMove_ThenDynamiteIsReturnedSometimes()
        {
            Player you = new Player("Test", new MyBot());
            you.Reset(GameRules.Default);
            short numberOfTimesDynamiteWasReturned = 0;
            short maxAttempts = 100;

            for (short i = 0; i < maxAttempts; i++)
            {
                if (you.GetRandomDynamiteMove() == Moves.Dynamite)
                    numberOfTimesDynamiteWasReturned++;
            }

            Assert.IsTrue(numberOfTimesDynamiteWasReturned < maxAttempts, "Too many dynamites thrown, not very random.");
            Assert.IsTrue(numberOfTimesDynamiteWasReturned > 0, "No dynamites thrown, not very random.");
            //To see the following output, view the test result details.
            Console.WriteLine("Actual dynamite thrown out of {0} was {1}.", maxAttempts, numberOfTimesDynamiteWasReturned);
        }
开发者ID:artlucia,项目名称:RockMeAzuredeus,代码行数:18,代码来源:MyBotExtensionsTest.cs

示例8: TestWhenNoDynamiteRemaining_ThenGetDynamiteMoveDoesNotThrowDynamite

        public void TestWhenNoDynamiteRemaining_ThenGetDynamiteMoveDoesNotThrowDynamite()
        {
            using (var mock = new MockGameRules
            {
                MaximumGames = 1,
                PointsToWin = 1,
                StartingDynamite = 0
            })
            {
                Player you = new Player("Test", new MyBot());
                you.Reset(mock.GetGameRules(GameRules.Default));

                Move notExpected = Moves.Dynamite;
                Move actual = MyBotExtensions.GetDynamiteMove(you);
                Assert.AreNotEqual(notExpected, actual, "Should not have resulted in dynamite when there is no dynamite left.");
            }
        }
开发者ID:artlucia,项目名称:RockMeAzuredeus,代码行数:17,代码来源:MyBotExtensionsTest.cs


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