diff --git a/dungeonbattle/mapgeneration/randomwalk.py b/dungeonbattle/mapgeneration/randomwalk.py index c0c807d..3c42559 100644 --- a/dungeonbattle/mapgeneration/randomwalk.py +++ b/dungeonbattle/mapgeneration/randomwalk.py @@ -1,9 +1,46 @@ +from enum import Enum from random import choice, random, randint from dungeonbattle.interfaces import Map, Tile - class Generator: - def __init__(self, params): + + +class Directions(Enum): + up = auto() + down = auto() + left = auto() + right = auto() + + +class Walker: + + def __init__(self, x, y): + self.x = x + self.y = y + self.dir = choice(list(Directions)) + + def random_turn(self): + self.dir = choice(list(Directions)) + + def next_pos(self): + if self.dir == Directions.up: + return self.x, self.y + 1 + elif self.dir == Directions.down: + return self.x, self.y - 1 + elif self.dir == Directions.right: + return self.x + 1, self.y + elif self.dir == Directions.left: + return self.x - 1, self.y + + def move_in_bounds(self, width, height): + nx, ny = self.next_pos() + if 0 < nx < width and 0 < ny < height: + self.x, self.y = nx, ny + + +class Generator: + + def __init__(self, params = DEFAULT_PARAMS): self.params = params def run(self):