public void Reset_Creates_New_Game() { var gameFactory = new CountdownGameFactory(10, 10); var router = new Router(); var controller = new AIController(new AIOptions(), gameFactory, router); var current = controller.CurrentGame; controller.Reset(); Assert.AreNotSame(current, controller.CurrentGame); }
static void Main(string[] args) => Parser.Default.ParseArguments <Options>(args) .WithParsed(o => { var gameFactory = new CountdownGameFactory(40, 20); var router = new Router(); var controllers = GetControllers(o.Players, o.AIPlayers, gameFactory, router); var gameManager = new GameManager(controllers); gameManager.Play(CancellationToken.None); });
public void Act_Moves_Snake_In_Game() { var gameFactory = new CountdownGameFactory(10, 10); var router = new Router(); var controller = new AIController(AIOptions.GetDefault(0), gameFactory, router); var startPos = controller.CurrentGame.Snake.GetHeadPosition(); var result = controller.Act(); var endPos = controller.CurrentGame.Snake.GetHeadPosition(); Assert.AreNotEqual(startPos, endPos); }
public void Reset_Creates_New_Hamiltonian_Cycle() { var gameFactory = new CountdownGameFactory(10, 10); var routerMock = new Mock <IRouter>(); var controller = new AIController(new AIOptions(), gameFactory, routerMock.Object); routerMock .Verify(m => m.HamiltonianCycle(It.IsAny <char[, ]>()), Times.Once); controller.Reset(); routerMock .Verify(m => m.HamiltonianCycle(It.IsAny <char[, ]>()), Times.Exactly(2)); }
public void Ctor_Uses_Id_From_Options() { const string EXPECTED_ID = "id"; var options = new AIOptions { Id = EXPECTED_ID }; var gameFactory = new CountdownGameFactory(10, 10); var router = new Router(); var controller = new AIController(options, gameFactory, router); Assert.AreEqual(EXPECTED_ID, controller.Id); }
public void Ctor_Uses_Color_From_Options() { const ConsoleColor EXPECTED_COLOR = ConsoleColor.Blue; var options = new AIOptions { Color = EXPECTED_COLOR }; var gameFactory = new CountdownGameFactory(10, 10); var router = new Router(); var controller = new AIController(options, gameFactory, router); Assert.AreEqual(EXPECTED_COLOR, controller.Color); }