public void InterfaceSupportsMoveCommand(Move botMove, string responseContent, string colorCommand, Color botColor) { // Arrange _bot.FindMove(Arg.Any <Board>(), Arg.Any <Color>()).Returns(botMove); _interface.ProcessCommand("tbi", _bot); _interface.ProcessCommand("tbi v1", _bot); _interface.ProcessCommand(colorCommand, _bot); // Act var response = _interface.ProcessCommand("move oooooooooooo/oB9o/o10o/o10o/o10o/o10o/o10o/o10o/o10o/o10o/o9Ro/oooooooooooo", _bot); // Assert Assert.That(response.Content, Is.EqualTo(responseContent)); Assert.That(response.WaitForNextCommand, Is.True); _bot.Received(1).FindMove(Arg.Is <Board>(b => b != null && b.Width == 12 && b.Height == 12), botColor); }
public static Result Run(IBot blue, IBot red, Board initialState) { var competitionBoard = initialState.Clone(); var competition = new Competition(competitionBoard); while (true) { var blueMove = blue.FindMove(competitionBoard.Clone(), Color.Blue); var redMove = red.FindMove(competitionBoard.Clone(), Color.Red); var blueCrashed = !competition.GetAvailableMoves(Color.Blue).Contains(blueMove); var redCrashed = !competition.GetAvailableMoves(Color.Red).Contains(redMove); if (blueCrashed && redCrashed) { return Result.Draw; } if (blueCrashed) { return Result.RedWon; } if (redCrashed) { return Result.BlueWon; } competition.MakeMove(Color.Blue, blueMove); if (!competition.GetAvailableMoves(Color.Red).Contains(redMove)) { return Result.Draw; } competition.MakeMove(Color.Red, redMove); } }