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


C# Game.MakeNextMove方法代码示例

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


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

示例1: GivenGameInitializes_WhenAPlayerTicksWinningCombination_ThenPlayer1ShouldWin

        public void GivenGameInitializes_WhenAPlayerTicksWinningCombination_ThenPlayer1ShouldWin()
        {
            // Assign
            var game = new Game(new BoardDisplayer());
            game.InitializeBoard();
            game.MakeNextMove(Player.Player1, 0);
            game.MakeNextMove(Player.Player1, 1);
            game.MakeNextMove(Player.Player1, 2);

            // Act
            var hasPlayerWon = game.HasPlayerWon(Player.Player1);

            // Assert
            Assert.IsTrue(hasPlayerWon);
        }
开发者ID:cemsezer,项目名称:Noughts-and-Crosses,代码行数:15,代码来源:NoughtsAndCrossesTests.cs

示例2: GivenGameInitializes_WhenAPlayerNotWins_ThenShouldNotDisplayResult

        public void GivenGameInitializes_WhenAPlayerNotWins_ThenShouldNotDisplayResult()
        {
            // Assign
            var boardDisplayerMock = new Mock<IBoardDisplayer>();
            var game = new Game(boardDisplayerMock.Object);
            game.InitializeBoard();
            game.MakeNextMove(Player.Player1, 0);

            // Act
            game.PlayAndCheck(Player.Player1);

            // Assert
            boardDisplayerMock.Verify(b => b.DisplayWinner(Player.Player1), Times.Never);
        }
开发者ID:cemsezer,项目名称:Noughts-and-Crosses,代码行数:14,代码来源:NoughtsAndCrossesTests.cs

示例3: GivenGameInitializes_WhenPlayer1MakesAMove_ThenBoardShouldShowThis

        public void GivenGameInitializes_WhenPlayer1MakesAMove_ThenBoardShouldShowThis()
        {
            // Assign
            var game = new Game(new BoardDisplayer());
            game.InitializeBoard();
            var randomCell = new Random().Next(0, 8);

            // Act
            game.MakeNextMove(Player.Player1, randomCell);

            // Assert
            for (var i = 0; i < game.Board.Cells.Count; i++)
            {
                if (i == randomCell)
                {
                    Assert.AreEqual(Player.Player1, game.Board.Cells[randomCell].Value);
                    continue;
                }

                Assert.IsFalse(game.Board.Cells[i].Value.HasValue);
            }
        }
开发者ID:cemsezer,项目名称:Noughts-and-Crosses,代码行数:22,代码来源:NoughtsAndCrossesTests.cs

示例4: GivenGameInitializes_WhenPlayersUseAllTheCells_ThenGameShouldFinish

        public void GivenGameInitializes_WhenPlayersUseAllTheCells_ThenGameShouldFinish()
        {
            // Assign
            var game = new Game(new BoardDisplayer());
            game.InitializeBoard();

            for (var i = 0; i < game.Board.Cells.Count; i++)
            {
                game.MakeNextMove(Player.Player1, i);
            }

            // Act
            bool isFinished = game.IsGameFinished();

            // Assert
            Assert.IsTrue(isFinished);
        }
开发者ID:cemsezer,项目名称:Noughts-and-Crosses,代码行数:17,代码来源:NoughtsAndCrossesTests.cs

示例5: GivenGameInitializes_WhenGameStarts_ThenPlayersShouldPickRandomCells

        public void GivenGameInitializes_WhenGameStarts_ThenPlayersShouldPickRandomCells()
        {
            // Assign
            var game = new Game(new BoardDisplayer());
            game.InitializeBoard();

            // Act
            var player1CellIndex = game.GetNextRandomAvailableCellIndex();
            game.MakeNextMove(Player.Player1, player1CellIndex);

            var player2Cell = game.GetNextRandomAvailableCellIndex();
            game.MakeNextMove(Player.Player2, player2Cell);

            // Assert
            Assert.AreNotEqual(player1CellIndex, player2Cell);
        }
开发者ID:cemsezer,项目名称:Noughts-and-Crosses,代码行数:16,代码来源:NoughtsAndCrossesTests.cs


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