diff options
| author | Yon <anaseto@bardinflor.perso.aquilenet.fr> | 2023-09-17 08:39:04 (GMT) |
|---|---|---|
| committer | Yon <anaseto@bardinflor.perso.aquilenet.fr> | 2023-09-17 08:39:04 (GMT) |
| commit | dc2eb47df84ea17bfac6befb8bed7ce2a59e82fe (patch) | |
| tree | 791d410967635e91ae8b306198c878cb8bd90dfc | |
| parent | d78f2cdadf62ed37896f2ac6d768e9373bee0f85 (diff) | |
| download | boohu-master.zip boohu-master.tar.gz | |
| -rw-r--r-- | path.go | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1,6 +1,7 @@ package main import ( + "math/rand" "sort" "codeberg.org/anaseto/gruid" @@ -152,10 +153,16 @@ func (mp *monPath) Neighbors(p gruid.Point) []gruid.Point { keep := func(np gruid.Point) bool { return valid(np) && (d.Cell(np).T != WallCell || mp.wall) } + var nb []gruid.Point if mp.monster.Status(MonsConfused) { - return mp.nbs.Cardinal(p, keep) + nb = mp.nbs.Cardinal(p, keep) + } else { + nb = mp.nbs.All(p, keep) } - return mp.nbs.All(p, keep) + rand.Shuffle(len(nb), func(i, j int) { + nb[i], nb[j] = nb[j], nb[i] + }) + return nb } func (mp *monPath) Cost(from, to gruid.Point) int { |
