private Boolean isWall(Position pos) { if (pos.getX() < 0 || pos.getY() < 0 || pos.getX() > valueMap.Length - 1 || pos.getY() > valueMap[0].Length - 1) { return(true); } return(valueMap[pos.getX()][pos.getY()] == 0); }
public override string[] calculatePath() { List <string> path = new List <string>(); while (goalPos.Count > 0) { Position target = new Position(-3, -3); string[] pathstep = new string[0]; foreach (Position position in goalPos) { if (target.getX() == -3 && target.getY() == -3) { target = position; pathstep = getPathTo(position); continue; } string[] tmp = getPathTo(position); if (tmp.Length < pathstep.Length) { target = position; pathstep = tmp; } } path.AddRange(pathstep); agent.reset(target); goalPos.Remove(target); } return(path.ToArray()); }
public int getDistanceTo(Position target) { return(Math.Abs((x) - target.getX()) + Math.Abs((y) - target.getY())); }