예제 #1
0
        internal static List <Cluster> Clusterize(Dictionary <long, ActualUnit> vehicles)
        {
            Nuclear.ClearInfo();
            List <Cluster> clusters = new List <Cluster>();

            foreach (ActualUnit unit in vehicles.Values)
            {
                if (unit.Durability > 0)
                {
                    bool newCluster = true;
                    foreach (var c in clusters)
                    {
                        if (c.IsNear(unit))
                        {
                            c.Add(unit);
                            newCluster = false;
                            break;
                        }
                    }

                    if (newCluster)
                    {
                        clusters.Add(new Cluster(unit));
                    }
                }
            }
            return(clusters);
        }
예제 #2
0
        void InitializeTick(Player me, Move move)
        {
            if (World.TickIndex == 0)
            {
                TerranTypes = new Dictionary <TerrainType, double>();
                TerranTypes.Add(TerrainType.Forest, Game.ForestTerrainVisionFactor);
                TerranTypes.Add(TerrainType.Plain, Game.PlainTerrainVisionFactor);
                TerranTypes.Add(TerrainType.Swamp, Game.SwampTerrainVisionFactor);

                foreach (Vehicle v in World.NewVehicles)
                {
                    if (v.PlayerId == me.Id)
                    {
                        vehicles.Add(v.Id, new ActualUnit(v));
                    }
                    else
                    {
                        enemies.Add(v.Id, new ActualUnit(v));
                    }
                }

                UpdateUnits(World);

                var friendlyClusters = Clusterer.Clusterize(vehicles);
                EnemyClusters = Clusterer.Clusterize(enemies);
                squads.Clear();
                Calc.ResetIds();
                friendlyClusters.ForEach(c => squads.Add(new Squad(c, friendlyClusters)));
                Commander.Reassign(squads);
            }
            else
            {
                UpdateUnits(World);
                EnemyClusters.ForEach(c => c.Update());
            }
            squads.RemoveAll(s => s.Cluster.Count == 0);
            squads.ForEach(s => s.Step());
            Commander.Update(World, move, me, squads);
            // Render.Update(enemies, vehicles, squads, EnemyClusters, Commander.Commands);

            if (World.TickIndex % 200 == 0 && World.TickIndex > 0)
            {
                EnemyClusters = Clusterer.Clusterize(enemies);
            }

            Nuclear.Step(move, World, me, Game, squads, EnemyClusters);
        }