This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tiny_road.py
73 lines (54 loc) · 1.47 KB
/
tiny_road.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
#coding=utf-8
import random
SCENES = ["town", "forest"]
SKY = ["🌕", "🌙", "☁️", "☁️", "🚁"]
TOWN_TILES = ["🏢", "🏫", "🌳", "🏥", "🏪", "⛪"]
FOREST_TILES = ["🌲", "🌲", "🌲", "🦌", "🌳", "🌳", "🌳"]
ROAD_TILES = ["🚙", "🚗", "🚓", "🚕", "🚲"]
def make_tiny_road():
sky = make_sky()
sidewalk = make_sidewalk()
road = make_road()
set_the_scene = (
sky + "\n" + \
sidewalk[0] + "\n" + \
road[0] + "\n" + \
road[1]
)
return set_the_scene
def make_sidewalk():
sidewalk = []
scene = random.choice(SCENES)
row = ""
if scene == "town":
tileset = TOWN_TILES
elif scene == "forest":
tileset = FOREST_TILES
for spot in range(12):
row += random.choice(tileset)
sidewalk.append(row)
return sidewalk
def make_road():
road = []
tileset = ROAD_TILES
for row in range(2):
row = ""
for spot in range(12):
tile = random.randint(0,100)
if tile%5 == 0:
row += random.choice(tileset)
else:
row += " "
road.append(row)
return road
def make_sky():
sky = ""
tile = random.choice(SKY)
for _ in range(12):
sky += " "
tile_placement = random.randint(0,len(sky)-1)
sky = sky[:tile_placement] + tile + sky[tile_placement:]
return sky
if __name__ == "__main__":
make_tiny_road()