-
Notifications
You must be signed in to change notification settings - Fork 1
/
presentacion.py
101 lines (89 loc) · 2.15 KB
/
presentacion.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from turtle import *
from simplegraph import *
redLines = True
maze = SimpleGraph({
50: (-1, 30, -1, -1),
30: (32, -1, -1, 50),
32: (33, 12, 30, -1),
33: (-1, -1, 32, 53),
53: (54, 33, 51, -1),
51: (53, 41, -1, -1),
41: (42, -1, -1, 51),
42: (-1, -1, 41, -1),
54: (-1, 34, 53, -1),
34: (35, -1, -1, 54),
35: (-1, -1, 34, 55),
55: (-1, 35, -1, -1),
12: (13, 2, -1, 32),
13: (-1, -1, 12, -1),
2: (4, -1, 1, 12),
4: (-1, -1, 2, 24),
24: (25, 4, 23, -1),
23: (24, -1, -1, -1),
25: (-1, 5, 24, -1),
5: (-1, -1, -1, 25),
1: (2, -1, -1, 21),
21: (-1, 1, 20, -1),
20: (21, 0, -1, -1),
0: (-1, -1, -1, 20)
})
def stop():
left(90)
done()
def toCoord(node):
f, c = node // 10, node % 10
return -210 + (84 * c), 210 + (-84 * f)
def fly(x, y=None):
penup()
goto(x, y)
pendown()
def drawPaths(node):
maze[node] = False
for ch in maze[node]:
if ch != -1 and maze.isenabled(ch):
fly(toCoord(node))
goto(toCoord(ch))
dot(5, 'black')
if redLines:
pen(pencolor='black')
write("{} {}".format(ch // 10, ch % 10),
align="center", font=("Consolas", 12, "bold"))
if redLines:
pen(pencolor='red')
drawPaths(ch)
dot(15, '#33ff99')
def drawMaze(start=50):
# { frame
fly(-252, 252)
pensize(5)
for i in range(4):
forward(504)
right(90)
# }
pensize(1)
# { colums and row
for i in range(-168, 252, 84):
left(90)
fly(i, -252)
forward(504)
right(90)
fly(-252, i)
forward(504)
# }
fly(toCoord(start))
write("{} {}".format(start // 10, start % 10),
align="center", font=("Consolas", 12, "bold"))
dot(15, '#9999ff')
if redLines:
pen(pencolor='red', pensize=2)
drawPaths(start)
if redLines:
pen(pencolor='black')
fly(toCoord(start))
dot(15, '#9999ff')
if __name__ == '__main__':
setup(1000, 800) # width, height
speed(10)
shapesize(0.8, 0.8, 0.3)
drawMaze()
stop()