public IEnumerable <IMazeCrawler> GetSwarm(IMazeCrawlerState requestor) { Trace($"Checking possible routes from crawler {requestor.Id} location."); // Determines the next possible Direction that can be done from the requestor's current Coordinates. // Create a MazeCrawler for each Direction. var nextSteps = new List <Direction>(); if (requestor.CanMove(Direction.North)) { Trace($"Crawler {requestor.Id} can move North."); nextSteps.Add(Direction.North); } if (requestor.CanMove(Direction.South)) { Trace($"Crawler {requestor.Id} can move South."); nextSteps.Add(Direction.South); } if (requestor.CanMove(Direction.East)) { Trace($"Crawler {requestor.Id} can move East."); nextSteps.Add(Direction.East); } if (requestor.CanMove(Direction.West)) { Trace($"Crawler {requestor.Id} can move West."); nextSteps.Add(Direction.West); } var newStart = new Coordinates(requestor.CurrentX, requestor.CurrentY); var newMap = MaskMap(); var crawlers = new List <IMazeCrawler>(); foreach (var direction in nextSteps) { var context = new MazeCrawlerContext { Start = newStart, Destination = _destination, NavigationMap = newMap, Coordinator = this, NavigationMode = requestor.NavigationMode }; var crawler = _spawner.Spawn(context); Trace($"Moving crawler {requestor.Id} into position."); crawler.Move(direction); crawlers.Add(crawler); } return(crawlers); }
public void Debrief(IMazeCrawlerState requestor) { Trace($"Updating findings from Crawler {requestor.Id}."); UpdateMap(requestor.CrawlerMap); }
public ISwarmCoordinator RequestSwarm(IMazeCrawlerState requestor) { Trace($"Crawler {requestor.Id} requested for a swarm."); UpdateMap(requestor.CrawlerMap); return(this); }