Beispiel #1
0
        // Update heat and influence maps
        public void AdjustThermostat(IGameState state)
        {
            influenceMaps.Reset();

            foreach (Location e in state.EnemyHills)
            {
                if (!theirHills.Contains(e))
                {
                    heatMap.SetCellCentre(e);
                    theirHills.Add(e);
                }
            }

            if (masterPlan == MasterPlan.WORLDDOMINATION)
            {
                foreach (Location e in theirHills)
                {
                    heatMap.ResetCell(e);
                    heatMap.UpdateCell(e, 15f);
                }
            }
            else if (masterPlan == MasterPlan.YOU_SHALLNOT_PAAAASSSS)
            {
                foreach (Location e in myHills)
                {
                    heatMap.SetCellCentre(e);
                    heatMap.ResetCell(e);
                    heatMap.UpdateCell(e, 15f);
                }
            }

            heatMap.UpdateAllCells(0.2f, 10);

            foreach (Ant tnA in state.EnemyAnts)
            {
                influenceMaps["Enemies"].AddSource(tnA);
            }

            foreach (Ant tnA in state.MyAnts)
            {
                influenceMaps["Friends"].AddSource(tnA);
            }

            /*
             * for (int x = 0; x < state.Width; x++ )
             *  for(int y = 0; y < state.Height; y++)
             *      if (state[y, x] == Tile.Water)
             *          influenceMaps["Walls"][new Location(y, x)] = 2;
             */

            influenceMaps["Enemies"].InvertWeight(masterPlan == MasterPlan.WORLDDOMINATION);
        }
Beispiel #2
0
        // Initialise at first step
        public void Init(IGameState state)
        {
            random       = new Random();
            currentTasks = new Dictionary <string, CurrentTask>();
            nextTasks    = new Dictionary <string, CurrentTask>();
            myHills      = new List <Location>(state.MyHills);
            theirHills   = new List <Location>();
            yummies      = new List <Location>();
            timRobbins   = new List <Location>();
            martinSheen  = new List <Location>();
            viewRadius   = (int)Math.Sqrt(state.ViewRadius2);
            heatMap      = new HeatMap(viewRadius, state);

            influenceMaps            = new LayeredInfluenceMap(state);
            influenceMaps["Enemies"] = new InfluenceMap(state, 4, 1);
            influenceMaps["Friends"] = new InfluenceMap(state, 1, 1);

            foreach (Location h in myHills)
            {
                heatMap.UpdateCell(h, -5f);

                Location tim;
                tim = h + new Location(-1, -1);
                if (state.GetIsPassable(tim))
                {
                    timRobbins.Add(tim);
                }

                tim = h + new Location(-1, 1);
                if (state.GetIsPassable(tim))
                {
                    timRobbins.Add(tim);
                }

                tim = h + new Location(1, -1);
                if (state.GetIsPassable(tim))
                {
                    timRobbins.Add(tim);
                }

                tim = h + new Location(1, 1);
                if (state.GetIsPassable(tim))
                {
                    timRobbins.Add(tim);
                }
            }
        }
Beispiel #3
0
        // Initialise at first step
        public void Init(IGameState state)
        {
            random = new Random();
            currentTasks = new Dictionary<string, CurrentTask>();
            nextTasks = new Dictionary<string, CurrentTask>();
            myHills = new List<Location>(state.MyHills);
            theirHills = new List<Location>();
            yummies = new List<Location>();
            timRobbins = new List<Location>();
            martinSheen = new List<Location>();
            viewRadius = (int)Math.Sqrt(state.ViewRadius2);
            heatMap = new HeatMap(viewRadius, state);

            influenceMaps = new LayeredInfluenceMap(state);
            influenceMaps["Enemies"] = new InfluenceMap(state, 4, 1);
            influenceMaps["Friends"] = new InfluenceMap(state, 1, 1);

            foreach (Location h in myHills)
            {
                heatMap.UpdateCell(h, -5f);

                Location tim;
                tim = h + new Location(-1, -1);
                if (state.GetIsPassable(tim))
                    timRobbins.Add(tim);

                tim = h + new Location(-1, 1);
                if (state.GetIsPassable(tim))
                    timRobbins.Add(tim);

                tim = h + new Location(1, -1);
                if (state.GetIsPassable(tim))
                    timRobbins.Add(tim);

                tim = h + new Location(1, 1);
                if (state.GetIsPassable(tim))
                    timRobbins.Add(tim);
            }
        }