Cleaned up drunken walk, closes #11

This commit is contained in:
m
2023-07-23 01:03:10 -04:00
parent d7fa6069f8
commit abf3e3a719
2 changed files with 10 additions and 5 deletions

View File

@@ -17,12 +17,14 @@ function DrunkenWalk:initialize(w, h)
end
function DrunkenWalk:update()
self.curr_x = self.curr_x + math.random(-1, 1)
self.curr_y = self.curr_y + math.random(-1, 1)
while self.curr_x >= self.map_w or self.curr_x < 0 or self.curr_y >= self.map_h or self.curr_y < 0 do
self.curr_x = self.curr_x + math.random(-1, 1)
self.curr_y = self.curr_y + math.random(-1, 1)
new_x = self.curr_x + math.random(-1, 1)
new_y = self.curr_y + math.random(-1, 1)
while new_x >= self.map_w or new_x < 0 or new_y >= self.map_h or new_y < 0 do
new_x = self.curr_x + math.random(-1, 1)
new_y = self.curr_y + math.random(-1, 1)
end
self.curr_x = new_x
self.curr_y = new_y
visualizer.map:draw_floor(self.curr_x, self.curr_y)
self.iterations = self.iterations - 1
if self.iterations == 0 then

View File

@@ -48,6 +48,9 @@ void AlgorithmManager::tick_algorithm() {
auto update_result = this->loaded_algorithm->update();
if(update_result.valid()) {
algorithm_done = update_result;
if(algorithm_done) {
Logger::log(LogLevel::DEBUG, "Finished running algorithm");
}
}
else {
algorithm_done = true;