feature/rla-11_AlgorithmsP1 #12
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user