public override ActionType GetNextAction(TravelWorld world) { if (CurrentLocation == _targetPlace) { return(noOpertion); } TravelPath path = world.ShortestClearPath(CurrentLocation, _targetPlace); if (path == null || path.Count() == 0) { return(noOpertion); } int nextPlace = path.First(); return(new ActionType(w => drive(w, nextPlace))); }
public void ClearPathTest() { TravelWorld world = new TravelWorld(); world.AddPlaces(1, 2, 3, 4, 5); for (int i = 1; i <= 4; i++) { world.AddWay(i, i + 1, 1); } world.AddWay(5, 1, 1); world.SetFire(1, 2); var path = world.ShortestClearPath(1, 3); var resPath = new TravelPath(); resPath.Add(5, 1); resPath.Add(4, 1); resPath.Add(3, 1); Assert.IsTrue(resPath.Equals(path)); }