summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-pathfind.cc
diff options
context:
space:
mode:
authorMark Mackey <atomjack@users.sourceforge.net>2010-11-05 15:23:35 +0000
committerMark Mackey <atomjack@users.sourceforge.net>2010-11-05 15:23:35 +0000
commit4080d7d1ebf51243d9da41fc2b10790858bb6bc7 (patch)
tree6fc6b7c965781611103d2ce98d0ef9b6ea8bd508 /crawl-ref/source/mon-pathfind.cc
parentd24286dc2d4bc4c0ef570b3d4cf5e87ee5a4d3e2 (diff)
downloadcrawl-ref-4080d7d1ebf51243d9da41fc2b10790858bb6bc7.tar.gz
crawl-ref-4080d7d1ebf51243d9da41fc2b10790858bb6bc7.zip
Increased trap cost and shuffled around.
Made trap costs dependent on the number of traps. Possibly too high atm. Fixed zot map 3 Added zot map 4 - still needs balancing Added a small amount of randomisation to the monster pathfinding A* algorithm. Made blade traps break eventually
Diffstat (limited to 'crawl-ref/source/mon-pathfind.cc')
-rw-r--r--crawl-ref/source/mon-pathfind.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/crawl-ref/source/mon-pathfind.cc b/crawl-ref/source/mon-pathfind.cc
index 4ff3147f1d..9c971bc452 100644
--- a/crawl-ref/source/mon-pathfind.cc
+++ b/crawl-ref/source/mon-pathfind.cc
@@ -9,6 +9,7 @@
#include "mon-stuff.h"
#include "mon-util.h"
#include "monster.h"
+#include "random.h"
#include "terrain.h"
#include "traps.h"
@@ -188,12 +189,16 @@ bool monster_pathfind::calc_path_to_neighbours()
// / | \ of (dir = 0) once dir has passed 7.
// 7 4 5
//
- for (int dir = 1; dir < 8; (dir += 2) == 9 && (dir = 0))
+ // To avoid bias, we'll choose a random 90 degree rotation
+ int rotate=random2(4)*2; // equal probability of 0,2,4,6
+ for (int idir = 1; idir < 8; (idir += 2) == 9 && (idir = 0))
{
// Skip diagonal movement.
- if (!allow_diagonals && (dir % 2))
+ if (!allow_diagonals && (idir % 2))
continue;
+ int dir = (idir + rotate) % 8; // apply our random 90 degree rotation
+
npos = pos + Compass[dir];
#ifdef DEBUG_PATHFIND