Esempio n. 1
0
File: gen.py Progetto: jlund3/pyre
def _create_room(pos, room_dim, room_chance):
    if dice.chance(room_chance):
        dim = dice.rand_coordinate(3, 3, room_dim[0] - 1, room_dim[1] - 1)
    else:
        dim = types.Coordinate(1, 1)
    off_max = room_dim - dim
    off = dice.rand_coordinate(1, 1, off_max[0], off_max[1])
    return pos + off, pos + off + dim
Esempio n. 2
0
File: gen.py Progetto: jlund3/pyre
def add_doors(grid, open_chance=0, door_chance=1):
    """Writes True where a doors should go"""
    for door in _find_doors(grid):
        if dice.chance(door_chance):
            grid[door] = dice.chance(open_chance)
Esempio n. 3
0
File: gen.py Progetto: jlund3/pyre
def chance_fill(grid, probability=.5):
    """Writes True to each tile with the given probability, False otherwise"""
    for x in xrange(grid.cols):
        for y in xrange(grid.rows):
            grid[x, y] = dice.chance(probability)
Esempio n. 4
0
File: gen.py Progetto: jlund3/pyre
 def reset(self):
     """Resets the state to a random configuration"""
     for x in xrange(1, self.cols - 1):
         for y in xrange(1, self.rows - 1):
             self.state[y][x] = dice.chance(0.6)