-
Notifications
You must be signed in to change notification settings - Fork 0
/
done-improved.py
87 lines (66 loc) · 1.28 KB
/
done-improved.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
import random
import turtle
colors=[
'blue',
'green',
'khaki',
'maroon',
'orange',
'peru',
'pink',
'purple',
'red',
'salmon',
'yellow'
]
players=[]
players_start=220
players_step=40
def create_turtle(color, start):
instance = turtle.Turtle()
instance.color(color)
instance.shape('turtle')
instance.penup()
instance.goto(-230, start)
instance.pendown()
if random.randint(0, 1) == 1:
instance.left(360)
else:
instance.right(360)
players.append(instance)
turtle.speed(10)
turtle.penup()
turtle.goto(-200, 250)
for step in range(20):
turtle.write(step + 1, align='center')
turtle.right(90)
turtle.forward(10)
turtle.pendown()
for dash in range(30):
turtle.forward(10)
turtle.penup()
turtle.forward(5)
turtle.pendown()
turtle.penup()
turtle.forward(20)
turtle.pendown()
turtle.write(step + 1, align='center')
turtle.penup()
turtle.backward(480)
turtle.left(90)
turtle.forward(20)
random.shuffle(colors)
for c in colors:
create_turtle(c, players_start - len(players) * players_step)
for turn in range(50):
for p in players:
p.forward(random.randint(1, 15))
max=0
winner=None
for p in players:
cur=p.pos()[0]
if cur > max:
max=cur
winner=p
winner.right(1710)
input('press enter to quit')