Autowalker is working way better and now I have a plan for using the AI in the System.
This commit is contained in:
parent
0623170dbc
commit
ee804581a8
11 changed files with 197 additions and 127 deletions
|
@ -78,13 +78,14 @@ bool Pathing::random_walk(Point &out, bool random, int direction, size_t dir_cou
|
|||
bool zero_found = false;
|
||||
dbc::check(dir_count == 4 || dir_count == 8, "Only 8 or 4 directions allowed.");
|
||||
|
||||
// just make a list of the four directions
|
||||
// first 4 directions are n/s/e/w for most enemies
|
||||
std::array<Point, 8> dirs{{
|
||||
{out.x,out.y-1}, // north
|
||||
{out.x+1,out.y}, // east
|
||||
{out.x,out.y+1}, // south
|
||||
{out.x-1,out.y}, // west
|
||||
|
||||
// the player and some enemies are more "agile"
|
||||
{out.x+1,out.y-1}, // north east
|
||||
{out.x+1,out.y+1}, // south east
|
||||
{out.x-1,out.y+1}, // south west
|
||||
|
@ -96,14 +97,14 @@ bool Pathing::random_walk(Point &out, bool random, int direction, size_t dir_cou
|
|||
|
||||
// pick a random start of directions
|
||||
// BUG: is uniform inclusive of the dir.size()?
|
||||
int rand_start = Random::uniform<int>(0, dirs.size());
|
||||
int rand_start = Random::uniform<int>(0, dir_count);
|
||||
|
||||
// go through all possible directions
|
||||
for(size_t i = 0; i < dir_count; i++) {
|
||||
// but start at the random start, effectively randomizing
|
||||
// which valid direction to go
|
||||
// BUG: this might be wrong given the above ranom from 0-size
|
||||
Point dir = dirs[(i + rand_start) % dirs.size()];
|
||||
Point dir = dirs[(i + rand_start) % dir_count];
|
||||
if(!shiterator::inbounds($paths, dir.x, dir.y)) continue; //skip unpathable stuff
|
||||
int weight = cur - $paths[dir.y][dir.x];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue