public override void CommandShips() { var list = new List <Projection>(); Fleet.AvailableShips.ForEach(s => list.Add(new Projection(s))); list = list.OrderBy(p => p.numTurns).ToList(); while (list.Count > 0) { // switch next to a ship on a dropoff if it's surrounded var next = list[0]; foreach (var proj in list.Where(l => l.ship.OnDropoff)) { if (proj.ship.Neighbors.All(n => Fleet.CollisionCells.Contains(n) || n.IsOccupied())) { next = proj; break; } } var s = next.ship; if (next.valuer.TurnsToFill(s, ValueMapping.IsPreviousTarget(s.Id, next.valuer.Target.position)) != next.numTurns) { list[list.IndexOf(next)] = new Projection(s); list.OrderBy(p => p.numTurns); continue; } Command move; if (!s.CanMove) { move = s.StayStill("Ship cannot move, forcing it to stay still... Target " + next.valuer.Target.position.ToString() + "... Expected Turns: " + next.numTurns); } else if (!(s.CurrentMapCell.Neighbors.Any(n => n.halite > GameInfo.UpperThirdAverage && n.halite > s.CellHalite * MyBot.HParams[Parameters.STAY_MULTIPLIER])) && s.CellHalite > GameInfo.UpperThirdAverage && Safety.IsSafeMove(s, Direction.STILL)) { move = s.StayStill("Forcing ship to sit still... Target " + next.valuer.Target.position.ToString() + "... Expected Turns: " + next.numTurns); } else { move = next.GetMove(); } DoMove(move, next.valuer.Target, next.ship.Id); list.Remove(next); } }
public Projection(Ship s) { this.valuer = ValueMapping.FindBestTarget(s); this.numTurns = this.valuer.TurnsToFill(s, ValueMapping.IsPreviousTarget(s.Id, this.valuer.Target.position)); this.ship = s; }