enable parallel walk of NPCs
This commit is contained in:
parent
366b79ecef
commit
b6deacbf14
1 changed files with 21 additions and 7 deletions
28
src/Util.hs
28
src/Util.hs
|
@ -133,11 +133,25 @@ astarAppl imgmat target start = aStar
|
||||||
|
|
||||||
naviGraph :: Matrix (Maybe ImgId) -> V2 Int -> HS.HashSet (V2 Int)
|
naviGraph :: Matrix (Maybe ImgId) -> V2 Int -> HS.HashSet (V2 Int)
|
||||||
naviGraph imgmat (V2 r c) =
|
naviGraph imgmat (V2 r c) =
|
||||||
let list = foldl
|
let list =
|
||||||
(\acc (or, oc) -> if null (imgObstacle $ imgmat M.! (r + or, c + oc))
|
foldl
|
||||||
then if or == 0 && oc == 0 then acc else V2 (r + or) (c + oc): acc
|
(\acc (or, oc) ->
|
||||||
else acc
|
if null (imgObstacle $ imgmat M.! (r + or, c + oc))
|
||||||
)
|
then V2 (r + or) (c + oc): acc
|
||||||
[]
|
else acc
|
||||||
[(0, 1), (0, -1), (1, 0), (-1, 0)]
|
)
|
||||||
|
[]
|
||||||
|
[(0, 1), (0, -1), (1, 0), (-1, 0)]
|
||||||
|
++
|
||||||
|
foldl
|
||||||
|
(\acc (or, oc) ->
|
||||||
|
if all null
|
||||||
|
(map
|
||||||
|
(\(oor, ooc) -> imgObstacle $ imgmat M.! (r + oor, c + ooc))
|
||||||
|
[(0, oc), (or, 0), (or, oc)])
|
||||||
|
then V2 (r + or) (c + oc): acc
|
||||||
|
else acc
|
||||||
|
)
|
||||||
|
[]
|
||||||
|
[(-1, -1), (-1, 1), (1, -1), (1, 1)]
|
||||||
in HS.fromList list
|
in HS.fromList list
|
||||||
|
|
Loading…
Reference in a new issue