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 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);
        }
Beispiel #4
0
        private static IEnumerable <IController> GetControllers(uint playerCount, uint aiCount, IGameFactory gameFactory,
                                                                IRouter router)
        {
            var result = new List <IController>();

            for (var i = 0; i < playerCount; i++)
            {
                result.Add(new PlayerController(PlayerOptions.GetDefault(i), gameFactory));
            }

            for (var i = 0; i < aiCount; i++)
            {
                result.Add(new AIController(AIOptions.GetDefault(i), gameFactory, router));
            }

            return(result);
        }
Beispiel #5
0
		public static float GetIslandPriceVP(MapCM map, int islandID, int playerID, AIOptions options)
		{
			float price = 0;
			IslandCM island = map.Islands[islandID];

			price += island.Horns * options.coefficients.HornVPT * options.turnsToEnd;
			price += island.HasMetro ? options.coefficients.MetroVP : 0;

			if (island.OwnerID != playerID)
			{
				price += island.Slots.Where(e => e != Build.None).Select(e => (Library.Map.IsNeedBuild(map, playerID, e) ? options.coefficients.NeedBuildVP : options.coefficients.NotNeedBuildVP)).Sum();
			}
			else
			{
				price += island.Slots.Where(e => e != Build.None).Select(e => options.coefficients.NeedBuildVP).Sum();
			}

			return price;
		}
Beispiel #6
0
 public void Setup()
 {
     _controller = new AIController(AIOptions.GetDefault(0), new CountdownGameFactory(Bounds, Bounds), new Router());
 }