-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aebc168
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#python3 | ||
|
||
import numpy as np | ||
|
||
|
||
class Map_thing: | ||
def __init__(self, t_char, mohs): | ||
self.t_char = t_char | ||
self.mohs = mohs | ||
|
||
def print_self(self): | ||
return self.t_char | ||
|
||
def get_mohs(self): | ||
return self.mohs | ||
|
||
class Map: | ||
def __init__(self, width, height, density ): | ||
self.width = width | ||
self.height = height | ||
self.density = density | ||
|
||
self._wall = Map_thing('',10) | ||
self._space = Map_thing(' ',0) | ||
|
||
self._map = [] | ||
|
||
def _init_map(self, density=None): | ||
den = density if density is not None else self.density | ||
for col in range(self.width): | ||
if col == 0 or col == self.width - 1: | ||
self._map.append([self._wall] * self.height) | ||
else: | ||
column = [self._wall] | ||
column.append([self._wall if np.random.randint(100) <= den else self._space for i in range(self.height - 2)]) | ||
column.append(self._wall) | ||
self._map.append(column) | ||
|
||
|
||
def _print(self): | ||
map_str = '' | ||
for i in range(self.width): | ||
for j in range(self.height): | ||
map_str += self._map[i][j].t_char | ||
return map_str | ||
|
||
|
||
if __name__ == "__main__": | ||
m = Map(10, 10, 50) | ||
print(m._print()) | ||
|
||
|