예제 #1
0
        public static void ProcessTurn()
        {
            // first make dropoffs...
            foreach (var ship in Fleet.AllShips)
            {
                if (GameInfo.NextDropoff != null && ship.position.Equals(GameInfo.NextDropoff.Position) && CanCreateDropoff(ship.position))
                {
                    Fleet.AddMove(ship.MakeDropoff());
                }
            }

            // iterate bestdropoffs to potentially select next dropoff...
            if (GameInfo.ReserveForDropoff && !ShouldCreateDropoff())
            {
                Log.LogMessage("drop-off: save for new dropoff disabled");
                GameInfo.ReserveForDropoff = false;
                GameInfo.NextDropoff       = null;
            }

            if (GameInfo.BestDropoffs.Any())
            {
                GameInfo.BestDropoffs = GameInfo.BestDropoffs.OrderByDescending(d => d.VirtualDropValue * Math.Pow(.95, GameInfo.MyClosestDropDistance(d.Position))).ToList();
                var bestDrop = GameInfo.BestDropoffs[0];

                if (!GameInfo.ReserveForDropoff && ShouldCreateDropoff() && bestDrop.Cell.MyClosestShips().Any(s => GameInfo.Distance(s.position, bestDrop.Position) <= s.DistanceToMyDropoff))
                {
                    Log.LogMessage("drop-off: save halite for newdropoff has been flagged as true");
                    GameInfo.ReserveForDropoff = true;
                }

                if (GameInfo.ReserveForDropoff && CanCreateDropoff(bestDrop.Position))
                {
                    GameInfo.NextDropoff = GameInfo.BestDropoffs[0];
                    Log.LogMessage($"Next dropoff flagged as {GameInfo.NextDropoff.Position.ToString()}");
                }
            }

            // Delete any dropoffs that have been mostly havested
            foreach (var d in GameInfo.BestDropoffs.ToList())
            {
                int halite = (int)d.VirtualDropValue;
                if (GameInfo.Map.At(d.Position).IsStructure || halite < HaliteCutoff)
                {
                    if (GameInfo.NextDropoff == d)
                    {
                        DeleteNextDropoff();
                    }
                    GameInfo.BestDropoffs.Remove(d);
                    Log.LogMessage($"drop-off at {d.Position.x},{d.Position.y} has been deleted... halite {halite}, cutoff {HaliteCutoff}");
                }
            }
        }
예제 #2
0
 private static double divisor = .71428; // It's 5 / 7
 public CellValuer(MapCell cell)
 {
     this.cell            = cell;
     this.value           = cell.halite;
     this.closestDropDist = GameInfo.MyClosestDropDistance(cell.position); // store to save computing resources...
 }