alias Cell.Restricted {
;$Cell.Restricted(cell) - returns if a cell (a1 thru s16) is land or inaccessible/restricted area
var %file map.ini, %x $left($1,1), %y $right($1,-1)
if (!%y) || (!%x) || ($len(%x $+ %y) < 2) || (%x !isalpha) || ($alph(%x) > 19) || (%y > 16) || (%y < 1) return $true
elseif ($readini(%file,landorsea,%x $+ %y) == land) return $true
elseif ($readini(%file,landorsea,%x $+ %y) == restricted) return $true
else return $false
}
alias FindPath {
;$FindPath(start,destination,N) - returns the estimated (straight line) path it will take to get to goal/destination
;if N is 1, returns cells to move and saves findpath q
;if N is 2, returns cells to move
;if N is 3, shows # of moves
var %current.x $left($1,1), %current.y $right($1,-1), %d.x $left($2,1), %d.y $right($2,-1)
var %total 0, %moves $1, %i 0
if ($3 == 1) hdel epirate.pathfind q
while (%i < 75) {
inc %i
if ($isodd(%i)) {
if ($alph(%current.x) < $alph(%d.x)) set %current.x $alph($calc($alph(%current.x) + 1))
elseif ($alph(%current.x) > $alph(%d.x)) set %current.x $alph($calc($alph(%current.x) - 1))
inc %total
}
else {
if (%current.y < %d.y) set %current.y $calc(%current.y + 1)
elseif (%current.y > %d.y) set %current.y $calc(%current.y - 1)
inc %total
}
set %current.x $upper(%current.x)
set %current.y $upper(%current.y)
set %moves $addtok(%moves,%current.x $+ %current.y,44)
if (%current.x == %d.x) && (%current.y == %d.y) {
set %total $gettok(%moves,0,44)
if ($3) {
if ($3 == 1) {
if (!$hget(pathfind)) hmake pathfind
hadd pathfind q $addtok($hget(pathfind,q),%moves,44)
return %moves
}
elseif ($3 == 2) return %moves
}
return %total
break
}
}
}