Cleaned up drunken walk, closes #11
This commit is contained in:
@@ -17,12 +17,14 @@ function DrunkenWalk:initialize(w, h)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function DrunkenWalk:update()
|
function DrunkenWalk:update()
|
||||||
self.curr_x = self.curr_x + math.random(-1, 1)
|
new_x = self.curr_x + math.random(-1, 1)
|
||||||
self.curr_y = self.curr_y + math.random(-1, 1)
|
new_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
|
while new_x >= self.map_w or new_x < 0 or new_y >= self.map_h or new_y < 0 do
|
||||||
self.curr_x = self.curr_x + math.random(-1, 1)
|
new_x = self.curr_x + math.random(-1, 1)
|
||||||
self.curr_y = self.curr_y + math.random(-1, 1)
|
new_y = self.curr_y + math.random(-1, 1)
|
||||||
end
|
end
|
||||||
|
self.curr_x = new_x
|
||||||
|
self.curr_y = new_y
|
||||||
visualizer.map:draw_floor(self.curr_x, self.curr_y)
|
visualizer.map:draw_floor(self.curr_x, self.curr_y)
|
||||||
self.iterations = self.iterations - 1
|
self.iterations = self.iterations - 1
|
||||||
if self.iterations == 0 then
|
if self.iterations == 0 then
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ void AlgorithmManager::tick_algorithm() {
|
|||||||
auto update_result = this->loaded_algorithm->update();
|
auto update_result = this->loaded_algorithm->update();
|
||||||
if(update_result.valid()) {
|
if(update_result.valid()) {
|
||||||
algorithm_done = update_result;
|
algorithm_done = update_result;
|
||||||
|
if(algorithm_done) {
|
||||||
|
Logger::log(LogLevel::DEBUG, "Finished running algorithm");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
algorithm_done = true;
|
algorithm_done = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user