Beispiel #1
0
        private Point2D NextTarget(VehiclesGroup myArmy, World world, Player me, Game game)
        {
            var enemyVehicles = VehicleRegistry.EnemyVehicles(me);

            if (world.TickIndex - lastClusteringTick <= CacheTtl)
            {
                return(cachedTarget);
            }
            var closestUncapturedFacility = VehicleRegistry.GetUncapturedFacilities(world, me, Id)
                                            .OrderBy(f => myArmy.Center.GetDistanceTo(f.ToPoint(game)))
                                            .FirstOrDefault();

            if (closestUncapturedFacility != null)
            {
                VehicleRegistry.SetCaptureTarget(closestUncapturedFacility.Id, Id);
                cachedTarget = closestUncapturedFacility.ToPoint(game);
                return(cachedTarget);
            }

            var nextEnemyGroup = NextEnemyGroup(myArmy.Center, enemyVehicles, world.TickIndex)?.ToList();

            if (nextEnemyGroup != null)
            {
                cachedTargetGroup  = nextEnemyGroup.Select(v => v.Id).ToList();
                cachedTarget       = nextEnemyGroup.GetCenterPoint();
                lastClusteringTick = world.TickIndex;
                return(cachedTarget);
            }

            return(new Point2D(world.Height, world.Width));
        }