-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtour.py
126 lines (96 loc) · 3.04 KB
/
tour.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from brain import Brain
class Tour:
def __init__(self, plist):
self.plist = plist
brain= Brain()
kategori = []
n = 0
for x in range(len(plist)):
n = n + int(plist[x])
if x == 0:
cate = 'CR'
elif x == 1:
cate = 'DF'
elif x == 2:
cate = 'TFT'
elif x == 3:
cate = 'SP'
elif x == 4:
cate = 'NP'
elif x == 5:
cate = 'TF2T'
else:
cate = 'RP'
if int(plist[x] > 0):
for k in range(int(plist[x])):
kategori.append(cate)
i = 0
result = [[0] * (n+1) for _ in range(n+1)]
result[0][0]=''
x=1
while x<n+1:
result[0][x] = kategori[x-1]
result[x][0] = kategori[x-1]
x+=1
result2 = []
while i < n-1:
j = i+1
c = 1
while j <n:
p1 = kategori[i]
p2 = kategori[j]
d = 0
p1p = ''
p2p = ''
p1p2 = ''
p2p2 = ''
pointp1 = 0
pointp2 = 0
while d < 20:
movep1= brain.return_player_type(p1,d,p2p,p2p2)
p1p2=p1p
p1p=movep1
movep2 = brain.return_player_type(p2,d,p1p,p1p2)
p2p2=p2p
p2p=movep2
if movep1== 'c' and movep2== 'c':
pointp1 = pointp1 + 4
pointp2 = pointp2 + 4
elif movep1=='c' and movep2=='d':
pointp2 = pointp2 + 5
elif movep1== 'd' and movep2== 'd':
pointp1 = pointp1 + 2
pointp2 = pointp2 + 2
elif movep1=='d' and movep2=='c':
pointp1 = pointp1 + 5
d = d+1
result[i+1][j+1]= str(pointp1) + '(' + str(pointp2) + ')'
result[j+1][i+1]=str(pointp2) + '(' + str(pointp1) + ')'
c = c+1
j = j+1
i = i+1
for a in result:
print(a)
for index,o in enumerate(result):
playerp = 0
for indexq,z in enumerate(o):
z=str(z)
if (z.split('(')[0]).isdigit():
playerp+=int(z.split('(')[0])
result2.append(playerp)
print('')
print(kategori)
print(result2[1:])
p=0
a=0
while p<n:
t=int(plist[a])
y=0
avg=0
while y<t:
avg+=result2[p+1]
y+=1
p+=1
if t!=0:
print(avg/t)
a+=1