Have a way to detect the best rotation but it's still off a bit. Seems to choose wrong in simple situations. Look in System::shortest_rotate.

This commit is contained in:
Zed A. Shaw 2025-09-01 01:37:03 -04:00
parent f98cc543f6
commit d822cb3438
6 changed files with 32 additions and 48 deletions

33
map.cpp
View file

@ -6,6 +6,7 @@
#include <fmt/core.h>
#include <utility>
#include "matrix.hpp"
#include "rand.hpp"
using std::vector, std::pair;
using namespace fmt;
@ -91,37 +92,9 @@ Point Map::center_camera(const Point &around, size_t view_x, size_t view_y) {
return {start_x, start_y};
}
/*
* Finds the next optimal neighbor in the path
* using either a direct or random method.
*
* Both modes will pick a random direction to start
* looking for the next path, then it goes clock-wise
* from there.
*
* In the direct method it will attempt to find
* a path that goes 1 lower in the dijkstra map
* path, and if it can't find that it will go to
* a 0 path (same number).
*
* In random mode it will pick either the next lower
* or the same level depending on what it finds first.
* Since the starting direction is random this will
* give it a semi-random walk that eventually gets to
* the target.
*
* In map generation this makes random paths and carves
* up the space to make rooms more irregular.
*
* When applied to an enemy they will either go straight
* to the player (random=false) or they'll wander around
* drunkenly gradually reaching the player, and dodging
* in and out.
*/
bool Map::random_walk(Point &out, bool random, int direction) {
(void)random;
dbc::log("!!!!!!!!!!!!!!!!!!!!!!!!!!!! REWRITE THIS!");
return $paths.find_path(out, direction, true) != PathingResult::FAIL;
int choice = Random::uniform(0,4);
return $paths.find_path(out, direction, random && choice == 0) != PathingResult::FAIL;
}
bool Map::INVARIANT() {