From abf3e3a7192fd9b82f42040fc0de1f68eed63631 Mon Sep 17 00:00:00 2001 From: m Date: Sun, 23 Jul 2023 01:03:10 -0400 Subject: [PATCH] Cleaned up drunken walk, closes #11 --- scripts/algorithms/drunk_walk.lua | 12 +++++++----- src/game/algorithmmanager.cpp | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/algorithms/drunk_walk.lua b/scripts/algorithms/drunk_walk.lua index 3134afe..77f6a05 100644 --- a/scripts/algorithms/drunk_walk.lua +++ b/scripts/algorithms/drunk_walk.lua @@ -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 diff --git a/src/game/algorithmmanager.cpp b/src/game/algorithmmanager.cpp index a204139..db8ad0f 100644 --- a/src/game/algorithmmanager.cpp +++ b/src/game/algorithmmanager.cpp @@ -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;