%Procedure to generate a path from (x1,y1) to (x2,y2)
var smallest : int := 240
var path : string := ""
var finalPath : string := ""
proc generatePath (x1, y1, x2, y2, count : int, movementType : string (1))
if x1 < 1 then
generatePath (intMapSize, y1, x2, y2, count, movementType)
return
end if
if x1 > intMapSize then
generatePath (1, y1, x2, y2, count, movementType)
return
end if
if y1 < 1 then
generatePath (x1, intMapSize, x2, y2, count, movementType)
return
end if
if y1 > intMapSize then
generatePath (x1, 1, x2, y2, count, movementType)
return
end if
if count > smallest or count > (2 * intMapSize) then
elsif strPathMarker (x1, y1) = "m" then
elsif movementType not= "f" and troopstack (x1, y1).tile < 48 then
elsif x1 = x2 and y1 = y2 then
smallest := min (count, smallest)
if count = smallest then
finalPath := path
end if
elsif strPathMarker (x1, y1) not= "m" then %Tile not marked
strPathMarker (x1, y1) := "m"
path += "e"
generatePath (x1 + 1, y1, x2, y2, count + 1, movementType)
path := path (1 .. * -1)
path += "w"
generatePath (x1 - 1, y1, x2, y2, count + 1, movementType)
path := path (1 .. * -1)
path += "n"
generatePath (x1, y1 + 1, x2, y2, count + 1, movementType)
path := path (1 .. * -1)
path += "s"
generatePath (x1, y1 - 1, x2, y2, count + 1, movementType)
path := path (1 .. * -1)
end if
end generatePath |