public Queue <ScheduleItem <T> > GetScheduleItems(ScheduleList <T> _list, T _startLocation, int _startTime = 0, int _pathLength = 8) { Bot <T> bot = GetBot(_list, _startLocation, _startTime, _pathLength); return(bot.ScheduleItems); }
public Queue <Instruction <T> > GetInstructions(ScheduleList <T> _list, T _startLocation, int _startTime = 0, int _pathLength = 8) { Bot <T> bot = GetBot(_list, _startLocation, _startTime, _pathLength); return(bot.Instructions); }
public Queue <T> GetPath(ScheduleList <T> _list, T _startLocation, int _startTime = 0, int _pathLength = 8) { Bot <T> bot = GetBot(_list, _startLocation, _startTime, _pathLength); return(bot.Path); }
public Bot <T> GetBot(ScheduleList <T> _list, T _startLocation, int _startTime = 0, int _pathLength = 8) { Reset(); float Discount = 1f; _list.ClampTime(_startTime, _startTime + _pathLength); CreateStartNode(_startLocation, _startTime, _list.GetSchedules(_startTime)); for (int i = 1; i <= _pathLength; i++) { // Determine all the bots that are able to move List <Bot <T> > oldBots = new List <Bot <T> >(); foreach (Node <T> node in NodeDictionary.Values) { if (node.FreeBot != null) { if (MaxBot != null && node.FreeBot.Score + _list.TotalPointsAvailable < MaxBot.Score) { node.FreeBot = null; } else { oldBots.Add(node.FreeBot); } } } foreach (Edge <T> edge in Edges) { edge.CheckOnTrappedBots(_list.TotalPointsAvailable, MaxBot != null ? MaxBot.Score : 0f); } foreach (Bot <T> bot in oldBots) { foreach (Edge <T> edge in bot.CurrentNode.Edges) { bot.TravelAlong(edge, _startTime + i); } } foreach (Node <T> node in NodeDictionary.Values) { node.CheckOnTrappedBots(_list.TotalPointsAvailable, MaxBot != null ? MaxBot.Score : 0f); if (node.FreeBot != null) { node.ApplyScore(_list.GetSchedules(_startTime + i), _startTime + i, Discount); if (MaxBot == null || node.FreeBot.Score > MaxBot.Score) { MaxBot = node.FreeBot; } } } Discount *= DiscountRate; } MaxBot.MakeDurations(); MaxBot.MakeInstructions(); MaxBot.MakeScheduleItems(); MaxBot.MakePath(); return(MaxBot); }