private void SimulatePacs(GameField field, SimInflMap inflMap, List <SimPac> pacs, int hops) { var time = 0; do { var timeLeft = hops - time; foreach (var pac in pacs) { if (pac.CurPath.Count > 0) { continue; } inflMap.Update(); inflMap.PlacePacs(pacs.Where(p => p.Id != pac.Id)); var len = Math.Min(10, timeLeft); var bestPath = field.FindBestPath(pac.Pos, 6, len, inflMap.CostMap, pac.LastPath.Count, hops); pac.CurPath = bestPath; foreach (var p in bestPath) { ++inflMap.CostMap[p]; } } var step = Math.Min(timeLeft, pacs.Min(p => p.CurPath.Count)); foreach (var pac in pacs) { pac.LastPath.AddRange(pac.CurPath.Take(step)); pac.Geathered += VisitPath(field, pac.CurPath.Take(step)); pac.LastPath.Value = pac.Geathered; pac.CurPath.RemoveRange(0, step); pac.Pos = pac.LastPath.Last(); } time += step; } while (time < hops); }
public Simulator(int h, int w) { _field = new GameField(); _baseCost = new Map <ushort>(h, w); _inflMap = new SimInflMap(_field, _baseCost, h, w); }