forked from Python3-Training/PyTrek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_MapSparse.py
50 lines (40 loc) · 1.15 KB
/
test_MapSparse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import random
import MapGame
import Glyphs
from MapSparse import SparseMap
def fill_map():
map = SparseMap()
map.init()
for sector in range(1, 65):
for xpos in range(8):
for ypos in range(8):
assert(map.plot(sector,xpos,ypos,Glyphs.ENTERPRISE))
return map
def define_map():
map = SparseMap()
map.init()
for ypos, area in enumerate(range(8)):
for xpos, area in enumerate(range(8)):
which = random.randint(0, 14)
glyph = Glyphs.SPACE
if which < 0:
pass
elif which < 8:
glyph = Glyphs.STAR
elif which < 13:
glyph = Glyphs.STARBASE
else:
glyph = Glyphs.KLINGON
map.plot(area,
random.randint(0, 7),
random.randint(0, 7),
glyph)
return map
if __name__ == '__main__':
map = fill_map()
for sect, area in enumerate(map.areas(),1):
assert(area.number == sect)
for sector in map.areas():
for line in sector.get_map():
print(line, end='')
print()