# CFL Engine A.0.2 - Marking Update

a guest
May 14th, 2021
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math
2. import random
3. import csv
4. import re
5.
7. players = []
8. with open('players.csv', newline='') as csvfile:
10. for row in reader:
11. players.append(row)
12.
13. #special rounding where X.YZ has a YZ% chance of being X+1 and a 1-YZ% chance of being X
14. def weightedround(x):
15. adjust_floor = math.floor(x)
18. if roll < x:
19. result = adjust_ceiling
20. else:
21. result = adjust_floor
22. return result
23.
24. #get rosters and other gameplan options
25. away_att = [1,2]
26. away_mid = [3,4,5]
27. away_def = [6,7,8]
28. away_keep = [9]
29. away_keepdepth = [3,3,3,2,2,1]
30. home_att = [10,11,12]
31. home_mid = [13,14]
32. home_def = [15,16,17]
33. home_keep = [18]
34. home_keepdepth = [3,2,2,2,1,1]
35.
36. away_roster = []
37. home_roster = []
38.
39. for i in away_att:
40. index = int(players[i][0])
41. position = players[i][1]
42. name = players[i][2]
43. traits = players[i][8]
44. POS = weightedround(int(players[i][12])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][13])-int(players[i][12])))
45. REA = weightedround(int(players[i][14])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][15])-int(players[i][14])))
46. HAN = weightedround(int(players[i][16])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][17])-int(players[i][16])))
47. MAR = weightedround(int(players[i][18])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][19])-int(players[i][18])))
48. TAC = weightedround(int(players[i][20])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][21])-int(players[i][20])))
49. PAS = weightedround(int(players[i][22])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][23])-int(players[i][22])))
50. DRI = weightedround(int(players[i][24])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][25])-int(players[i][24])))
51. OFF = weightedround(int(players[i][26])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][27])-int(players[i][26])))
52. VIS = weightedround(int(players[i][28])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][29])-int(players[i][28])))
53. FIN = weightedround(int(players[i][30])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][31])-int(players[i][30])))
54. ACC = weightedround(int(players[i][32])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][33])-int(players[i][32])))
55. AGG = int(players[i][34])
56. away_roster.append([index,position,name,traits,POS,REA,HAN,MAR,TAC,PAS,DRI,OFF,VIS,FIN,ACC,AGG])
57.
58. for i in away_mid:
59. index = int(players[i][0])
60. position = players[i][1]
61. name = players[i][2]
62. traits = players[i][8]
63. POS = weightedround(int(players[i][12])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][13])-int(players[i][12])))
64. REA = weightedround(int(players[i][14])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][15])-int(players[i][14])))
65. HAN = weightedround(int(players[i][16])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][17])-int(players[i][16])))
66. MAR = weightedround(int(players[i][18])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][19])-int(players[i][18])))
67. TAC = weightedround(int(players[i][20])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][21])-int(players[i][20])))
68. PAS = weightedround(int(players[i][22])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][23])-int(players[i][22])))
69. DRI = weightedround(int(players[i][24])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][25])-int(players[i][24])))
70. OFF = weightedround(int(players[i][26])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][27])-int(players[i][26])))
71. VIS = weightedround(int(players[i][28])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][29])-int(players[i][28])))
72. FIN = weightedround(int(players[i][30])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][31])-int(players[i][30])))
73. ACC = weightedround(int(players[i][32])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][33])-int(players[i][32])))
74. AGG = int(players[i][34])
75. away_roster.append([index,position,name,traits,POS,REA,HAN,MAR,TAC,PAS,DRI,OFF,VIS,FIN,ACC,AGG])
76.
77. for i in away_def:
78. index = int(players[i][0])
79. position = players[i][1]
80. name = players[i][2]
81. traits = players[i][8]
82. POS = weightedround(int(players[i][12])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][13])-int(players[i][12])))
83. REA = weightedround(int(players[i][14])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][15])-int(players[i][14])))
84. HAN = weightedround(int(players[i][16])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][17])-int(players[i][16])))
85. MAR = weightedround(int(players[i][18])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][19])-int(players[i][18])))
86. TAC = weightedround(int(players[i][20])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][21])-int(players[i][20])))
87. PAS = weightedround(int(players[i][22])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][23])-int(players[i][22])))
88. DRI = weightedround(int(players[i][24])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][25])-int(players[i][24])))
89. OFF = weightedround(int(players[i][26])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][27])-int(players[i][26])))
90. VIS = weightedround(int(players[i][28])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][29])-int(players[i][28])))
91. FIN = weightedround(int(players[i][30])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][31])-int(players[i][30])))
92. ACC = weightedround(int(players[i][32])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][33])-int(players[i][32])))
93. AGG = int(players[i][34])
94. away_roster.append([index,position,name,traits,POS,REA,HAN,MAR,TAC,PAS,DRI,OFF,VIS,FIN,ACC,AGG])
95.
96. for i in away_keep:
97. index = int(players[i][0])
98. position = players[i][1]
99. name = players[i][2]
100. traits = players[i][8]
101. POS = weightedround(int(players[i][12])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][13])-int(players[i][12])))
102. REA = weightedround(int(players[i][14])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][15])-int(players[i][14])))
103. HAN = weightedround(int(players[i][16])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][17])-int(players[i][16])))
104. MAR = weightedround(int(players[i][18])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][19])-int(players[i][18])))
105. TAC = weightedround(int(players[i][20])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][21])-int(players[i][20])))
106. PAS = weightedround(int(players[i][22])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][23])-int(players[i][22])))
107. DRI = weightedround(int(players[i][24])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][25])-int(players[i][24])))
108. OFF = weightedround(int(players[i][26])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][27])-int(players[i][26])))
109. VIS = weightedround(int(players[i][28])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][29])-int(players[i][28])))
110. FIN = weightedround(int(players[i][30])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][31])-int(players[i][30])))
111. ACC = weightedround(int(players[i][32])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][33])-int(players[i][32])))
112. AGG = int(players[i][34])
113. away_roster.append([index,position,name,traits,POS,REA,HAN,MAR,TAC,PAS,DRI,OFF,VIS,FIN,ACC,AGG])
114.
115. for i in home_att:
116. index = int(players[i][0])
117. position = players[i][1]
118. name = players[i][2]
119. traits = players[i][8]
120. POS = weightedround(int(players[i][12])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][13])-int(players[i][12])))
121. REA = weightedround(int(players[i][14])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][15])-int(players[i][14])))
122. HAN = weightedround(int(players[i][16])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][17])-int(players[i][16])))
123. MAR = weightedround(int(players[i][18])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][19])-int(players[i][18])))
124. TAC = weightedround(int(players[i][20])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][21])-int(players[i][20])))
125. PAS = weightedround(int(players[i][22])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][23])-int(players[i][22])))
126. DRI = weightedround(int(players[i][24])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][25])-int(players[i][24])))
127. OFF = weightedround(int(players[i][26])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][27])-int(players[i][26])))
128. VIS = weightedround(int(players[i][28])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][29])-int(players[i][28])))
129. FIN = weightedround(int(players[i][30])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][31])-int(players[i][30])))
130. ACC = weightedround(int(players[i][32])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][33])-int(players[i][32])))
131. AGG = int(players[i][34])
132. home_roster.append([index,position,name,traits,POS,REA,HAN,MAR,TAC,PAS,DRI,OFF,VIS,FIN,ACC,AGG])
133.
134. for i in home_mid:
135. index = int(players[i][0])
136. position = players[i][1]
137. name = players[i][2]
138. traits = players[i][8]
139. POS = weightedround(int(players[i][12])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][13])-int(players[i][12])))
140. REA = weightedround(int(players[i][14])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][15])-int(players[i][14])))
141. HAN = weightedround(int(players[i][16])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][17])-int(players[i][16])))
142. MAR = weightedround(int(players[i][18])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][19])-int(players[i][18])))
143. TAC = weightedround(int(players[i][20])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][21])-int(players[i][20])))
144. PAS = weightedround(int(players[i][22])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][23])-int(players[i][22])))
145. DRI = weightedround(int(players[i][24])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][25])-int(players[i][24])))
146. OFF = weightedround(int(players[i][26])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][27])-int(players[i][26])))
147. VIS = weightedround(int(players[i][28])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][29])-int(players[i][28])))
148. FIN = weightedround(int(players[i][30])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][31])-int(players[i][30])))
149. ACC = weightedround(int(players[i][32])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][33])-int(players[i][32])))
150. AGG = int(players[i][34])
151. home_roster.append([index,position,name,traits,POS,REA,HAN,MAR,TAC,PAS,DRI,OFF,VIS,FIN,ACC,AGG])
152.
153. for i in home_def:
154. index = int(players[i][0])
155. position = players[i][1]
156. name = players[i][2]
157. traits = players[i][8]
158. POS = weightedround(int(players[i][12])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][13])-int(players[i][12])))
159. REA = weightedround(int(players[i][14])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][15])-int(players[i][14])))
160. HAN = weightedround(int(players[i][16])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][17])-int(players[i][16])))
161. MAR = weightedround(int(players[i][18])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][19])-int(players[i][18])))
162. TAC = weightedround(int(players[i][20])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][21])-int(players[i][20])))
163. PAS = weightedround(int(players[i][22])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][23])-int(players[i][22])))
164. DRI = weightedround(int(players[i][24])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][25])-int(players[i][24])))
165. OFF = weightedround(int(players[i][26])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][27])-int(players[i][26])))
166. VIS = weightedround(int(players[i][28])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][29])-int(players[i][28])))
167. FIN = weightedround(int(players[i][30])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][31])-int(players[i][30])))
168. ACC = weightedround(int(players[i][32])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][33])-int(players[i][32])))
169. AGG = int(players[i][34])
170. home_roster.append([index,position,name,traits,POS,REA,HAN,MAR,TAC,PAS,DRI,OFF,VIS,FIN,ACC,AGG])
171.
172. for i in home_keep:
173. index = int(players[i][0])
174. position = players[i][1]
175. name = players[i][2]
176. traits = players[i][8]
177. POS = weightedround(int(players[i][12])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][13])-int(players[i][12])))
178. REA = weightedround(int(players[i][14])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][15])-int(players[i][14])))
179. HAN = weightedround(int(players[i][16])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][17])-int(players[i][16])))
180. MAR = weightedround(int(players[i][18])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][19])-int(players[i][18])))
181. TAC = weightedround(int(players[i][20])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][21])-int(players[i][20])))
182. PAS = weightedround(int(players[i][22])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][23])-int(players[i][22])))
183. DRI = weightedround(int(players[i][24])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][25])-int(players[i][24])))
184. OFF = weightedround(int(players[i][26])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][27])-int(players[i][26])))
185. VIS = weightedround(int(players[i][28])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][29])-int(players[i][28])))
186. FIN = weightedround(int(players[i][30])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][31])-int(players[i][30])))
187. ACC = weightedround(int(players[i][32])+random.gauss(0,0.25)+random.gauss(0.15,0.05)*(int(players[i][33])-int(players[i][32])))
188. AGG = int(players[i][34])
189. home_roster.append([index,position,name,traits,POS,REA,HAN,MAR,TAC,PAS,DRI,OFF,VIS,FIN,ACC,AGG])
190.
191. print(away_roster)
192. print(home_roster)
193.
194. half = 1
195. #roll extra time
196. extra_time = weightedround(max(random.gauss(150,45),0))
197. time = 900 + extra_time
198. print("The first half will be 15 minutes and feature",extra_time // 60,"minutes and",extra_time % 60,"seconds of extra time")
199.
200. #get kickoff possession
201. def kickoff(x):
202. global possession
203. global depth
204. global offense
205. global time
206. depth = 2
207. if x == "Home":
208. i = 0
209. while i < len(home_roster):
210. x = home_roster[i][0]
211. if x == home_mid[0]:
212. possession = i
213. i += 1
214. else:
215. i += 1
216. if time - extra_time <= 0:
217. minutes = str((time - extra_time) // 60)
218. seconds = str(-1*(time - extra_time) % 60)
219. timelist = [minutes,":",seconds.zfill(2)]
220. else:
221. minutes = str((time - extra_time) // 60)
222. seconds = str((time - extra_time) % 60)
223. timelist = [minutes,":",seconds.zfill(2)]
224. print("".join(timelist)," And there's the kickoff, with",home_roster[possession][2],"takes possession")
225. elif x == "Away":
226. i = 0
227. while i < len(away_roster):
228. x = away_roster[i][0]
229. if x == away_mid[0]:
230. possession = i
231. i += 1
232. else:
233. i += 1
234. if time - extra_time <= 0:
235. minutes = str((time - extra_time) // 60)
236. seconds = str(-1*(time - extra_time) % 60)
237. timelist = [minutes,":",seconds.zfill(2)]
238. else:
239. minutes = str((time - extra_time) // 60)
240. seconds = str((time - extra_time) % 60)
241. timelist = [minutes,":",seconds.zfill(2)]
242. print("".join(timelist)," And there's the kickoff, with",away_roster[possession][2],"takes possession")
243.
244. #if they'll take a shot
245. def takeshot(x):
246. global offense
247. global possession
248. global time
249. take_roll = random.randint(1,60 - x*10)
250. if offense == "Home":
251. y = home_roster[possession][15]
252. if take_roll > y:
253. result = False
254. elif take_roll <= y:
255. result = True
256. elif offense == "Away":
257. y = away_roster[possession][15]
258. if take_roll > y:
259. result = False
260. elif take_roll <= y:
261. result = True
262. return result
263.
264. #is shot on target
265. def ontarget():
266. global offense
267. global possession
268. global depth
269. global time
270. target_roll = random.randint(1,15 + depth * 15)
271. if offense == "Home":
272. y = home_roster[possession][14]
273. if target_roll > y:
274. result = False
275. elif target_roll <= y:
276. result = True
277. elif offense == "Away":
278. y = away_roster[possession][14]
279. if target_roll > y:
280. result = False
281. elif target_roll <= y:
282. result = True
283. time -= weightedround(random.gauss(6,1))
284. return result
285.
286. #Determining who's guarding who
287. def marking():
288. global possession
289. global offense
290. global marking_off
291. global marking_def
292. global depth
293. global time
294. away_att2 = away_att[:]
295. away_mid2 = away_mid[:]
296. away_def2 = away_def[:]
297. home_att2 = home_att[:]
298. home_mid2 = home_mid[:]
299. home_def2 = home_def[:]
300. marking_off = []
301. marking_def = []
302. if offense == "Home":
303. i = 0
304. while i < len(home_att2):
305. q = home_att2[i]
306. t = 0
307. while t < len(home_roster):
308. y = home_roster[t][0]
309. if y == q:
310. r = t
311. t += 1
312. else:
313. t += 1
314. marking_off.append(r)
315. try:
316. z = random.choice(away_def2)
317. away_def2.remove(z)
318. except:
319. z = random.choice(away_mid2)
320. away_mid2.remove(z)
321. t = 0
322. while t < len(away_roster):
323. y = away_roster[t][0]
324. if y == z:
325. s = t
326. t += 1
327. else:
328. t += 1
329. marking_def.append(s)
330. i += 1
331. i = 0
332. while i < len(home_mid2):
333. q = home_mid2[i]
334. t = 0
335. while t < len(home_roster):
336. y = home_roster[t][0]
337. if y == q:
338. r = t
339. t += 1
340. else:
341. t += 1
342. marking_off.append(r)
343. try:
344. try:
345. z = random.choice(away_def2)
346. away_def2.remove(z)
347. except:
348. z = random.choice(away_mid2)
349. away_mid2.remove(z)
350. except:
351. z = random.choice(away_att2)
352. away_att2.remove(z)
353. t = 0
354. while t < len(away_roster):
355. y = away_roster[t][0]
356. if y == z:
357. s = t
358. t += 1
359. else:
360. t += 1
361. marking_def.append(s)
362. i += 1
363. i = 0
364. while i < len(home_def2):
365. q = home_def2[i]
366. t = 0
367. while t < len(home_roster):
368. y = home_roster[t][0]
369. if y == q:
370. r = t
371. t += 1
372. else:
373. t += 1
374. marking_off.append(r)
375. try:
376. z = random.choice(away_mid2)
377. away_mid2.remove(z)
378. except:
379. z = random.choice(away_att2)
380. away_att2.remove(z)
381. t = 0
382. while t < len(away_roster):
383. y = away_roster[t][0]
384. if y == z:
385. s = t
386. t += 1
387. else:
388. t += 1
389. marking_def.append(s)
390. i += 1
391. elif offense == "Away":
392. i = 0
393. while i < len(away_att2):
394. q = away_att2[i]
395. t = 0
396. while t < len(away_roster):
397. y = away_roster[t][0]
398. if y == q:
399. r = t
400. t += 1
401. else:
402. t += 1
403. marking_off.append(r)
404. try:
405. z = random.choice(home_def2)
406. home_def2.remove(z)
407. except:
408. z = random.choice(away_mid2)
409. home_mid2.remove(z)
410. t = 0
411. while t < len(home_roster):
412. y = home_roster[t][0]
413. if y == z:
414. s = t
415. t += 1
416. else:
417. t += 1
418. marking_def.append(s)
419. i += 1
420. i = 0
421. while i < len(away_mid2):
422. q = away_mid2[i]
423. t = 0
424. while t < len(away_roster):
425. y = away_roster[t][0]
426. if y == q:
427. r = t
428. t += 1
429. else:
430. t += 1
431. marking_off.append(r)
432. try:
433. try:
434. z = random.choice(home_def2)
435. home_def2.remove(z)
436. except:
437. z = random.choice(home_mid2)
438. home_mid2.remove(z)
439. except:
440. z = random.choice(home_att2)
441. home_att2.remove(z)
442. t = 0
443. while t < len(home_roster):
444. y = home_roster[t][0]
445. if y == z:
446. s = t
447. t += 1
448. else:
449. t += 1
450. marking_def.append(s)
451. i += 1
452. i = 0
453. while i < len(away_def2):
454. q = away_def2[i]
455. t = 0
456. while t < len(away_roster):
457. y = away_roster[t][0]
458. if y == q:
459. r = t
460. t += 1
461. else:
462. t += 1
463. marking_off.append(r)
464. try:
465. z = random.choice(home_mid2)
466. home_mid2.remove(z)
467. except:
468. z = random.choice(home_att2)
469. home_att2.remove(z)
470. t = 0
471. while t < len(home_roster):
472. y = home_roster[t][0]
473. if y == z:
474. s = t
475. t += 1
476. else:
477. t += 1
478. marking_def.append(s)
479. i += 1
480.
481. #dribble and tackle function
482. def dribble():
483. global possession
484. global offense
485. global depth
486. global marking_off
487. global marking_def
488. global time
489. z = marking_off.index(possession)
490. y = marking_def[z]
491. if offense == "Home":
492. print(home_roster[possession][2],"on the ball with",away_roster[y][2],"defending.")
493.
494. elif offense == "Away":
495. print(away_roster[possession][2],"on the ball with",home_roster[y][2],"defending.")
496.
497.
498. #passing
499. def passattempt():
500. global possession
501. global offense
502. global depth
503. global time
504. if depth == 3:
505. x = random.choice([3,3,2,2])
506. depth = x
507. elif depth == 2:
508. x = random.choice([3,2,2,2,1,1])
509. depth = x
510. elif depth == 1:
511. x = random.choice([2,2,1,1])
512. depth = x
513. if offense == "Home":
514. pass
515.
516. elif offense == "Away":
517. pass
518.
519. #change possession macro
520. def changepossession(x):
521. global possession
522. global offense
523. global depth
524. global time
525. if x == 1: ##Shots off target//Keeper catches
526. i = 0
527. if offense == "Away":
528. offense = "Home"
529. while i < len(home_roster):
530. x = home_roster[i][0]
531. if x == home_keep[0]:
532. possession = i
533. keeper = i
534. i += 1
535. else:
536. i += 1
537. if "Distributor" in home_roster[keeper][3]:
538. distributor_bonus = 1
539. else:
540. distributor_bonus = 0
541. t = random.choice(home_keepdepth)
542. if t == 3: #return to defense
543. q = random.choice(home_def)
544. i = 0
545. while i < len(home_roster):
546. z = home_roster[i][0]
547. if z == q:
548. possession = i
549. i += 1
550. else:
551. i += 1
552. depth = 3
553. print("Keeper",home_roster[keeper][2],"rolls the ball to his defender",home_roster[possession][2])
554. elif t == 2: #return to midfield
555. z = random.randint(1+distributor_bonus,4)
556. if z > 2:
557. q = random.choice(home_mid)
558. i = 0
559. while i < len(home_roster):
560. z = home_roster[i][0]
561. if z == q:
562. possession = i
563. i += 1
564. else:
565. i += 1
566. depth = 2
567. print("Keeper",home_roster[keeper][2],"boots the ball into the midfield where it's collected by",home_roster[possession][2])
568. else:
569. q = random.choice(away_mid)
570. i = 0
571. while i < len(away_roster):
572. z = away_roster[i][0]
573. if z == q:
574. possession = i
575. i += 1
576. else:
577. i += 1
578. depth = 2
579. offense = "Away"
580. print("Keeper",home_roster[keeper][2],"boots the ball into the midfield, but it's stolen by",away_roster[possession][2])
581. elif t == 1: #push on the attack
582. z = random.randint(1+distributor_bonus,4)
583. if z == 4:
584. q = random.choice(home_att)
585. i = 0
586. while i < len(home_roster):
587. z = home_roster[i][0]
588. if z == q:
589. possession = i
590. i += 1
591. else:
592. i += 1
593. depth = 1
594. print("Keeper",home_roster[keeper][2],"pushes the ball deep into the attack and it connects to",home_roster[possession][2])
595. else:
596. q = random.choice(away_def)
597. i = 0
598. while i < len(away_roster):
599. z = away_roster[i][0]
600. if z == q:
601. possession = i
602. i += 1
603. else:
604. i += 1
605. depth = 3
606. offense = "Away"
607. print("Keeper",home_roster[keeper][2],"launches the ball over his teammates where it's easily collected by",away_roster[possession][2])
608. elif offense == "Home":
609. offense = "Away"
610. while i < len(away_roster):
611. x = away_roster[i][0]
612. if x == away_keep[0]:
613. possession = i
614. keeper = i
615. i += 1
616. else:
617. i += 1
618. if "Distributor" in away_roster[keeper][3]:
619. distributor_bonus = 1
620. else:
621. distributor_bonus = 0
622. t = random.choice(away_keepdepth)
623. if t == 3: #return to defense
624. q = random.choice(away_def)
625. i = 0
626. while i < len(away_roster):
627. z = away_roster[i][0]
628. if z == q:
629. possession = i
630. i += 1
631. else:
632. i += 1
633. depth = 3
634. print("Keeper",away_roster[keeper][2],"rolls the ball to his defender",away_roster[possession][2])
635. elif t == 2: #return to midfield
636. z = random.randint(1+distributor_bonus,4)
637. if z > 2:
638. q = random.choice(away_mid)
639. i = 0
640. while i < len(away_roster):
641. z = away_roster[i][0]
642. if z == q:
643. possession = i
644. i += 1
645. else:
646. i += 1
647. depth = 2
648. print("Keeper",away_roster[keeper][2],"boots the ball into the midfield where it's collected by",away_roster[possession][2])
649. else:
650. q = random.choice(home_mid)
651. i = 0
652. while i < len(home_roster):
653. z = home_roster[i][0]
654. if z == q:
655. possession = i
656. i += 1
657. else:
658. i += 1
659. depth = 2
660. offense = "Home"
661. print("Keeper",away_roster[keeper][2],"boots the ball into the midfield, but it's stolen by",home_roster[possession][2])
662. elif t == 1: #push on the attack
663. z = random.randint(1+distributor_bonus,4)
664. if z == 4:
665. q = random.choice(away_att)
666. i = 0
667. while i < len(away_roster):
668. z = away_roster[i][0]
669. if z == q:
670. possession = i
671. i += 1
672. else:
673. i += 1
674. depth = 1
675. print("Keeper",away_roster[keeper][2],"pushes the ball deep into the attack and it connects to",away_roster[possession][2])
676. else:
677. q = random.choice(home_def)
678. i = 0
679. while i < len(home_roster):
680. z = home_roster[i][0]
681. if z == q:
682. possession = i
683. i += 1
684. else:
685. i += 1
686. depth = 3
687. offense = "Home"
688. print("Keeper",away_roster[keeper][2],"launches the ball over his teammates where it's easily collected by",home_roster[possession][2])
689.
690. kickoff_flag = True
691. offense = "Away"
692. while time > 0:
693. while kickoff_flag == True:
694. print("KICKOFF")
695. if offense == "Away":
696. kickoff("Away")
697. elif offense == "Home":
698. kickoff("Home")
699. kickoff_flag = False
700. time -= weightedround(random.gauss(10,2.5))
701. if takeshot(1) == True:
702. if ontarget() == True:
703. if offense == "Home":
704. print("Shot taken by",home_roster[possession][2]," and it's on target.")
705. kickoff_flag = True
706. offense = "Away"
707. print("CONTINUE")
708. continue
709. elif offense == "Away":
710. print("Shot taken by",away_roster[possession][2]," and it's on target.")
711. kickoff_flag = True
712. offense = "Home"
713. print("CONTINUE")
714. continue
715. else:
716. if offense == "Home":
717. print("Shot taken by",home_roster[possession][2]," but it's off-target.")
718. changepossession(1)
719. elif offense == "Away":
720. print("Shot taken by",away_roster[possession][2]," but it's off-target.")
721. changepossession(1)
722. marking()
723. dribble()
724.
725. Example results:
726. =============================================================================== RESTART: C:\Users\roman\OneDrive\Desktop\Colosseum League Football\Engine.py ===============================================================================
727. [[1, 'ST', 'Striker 1', '[]', 2, 1, 3, 2, 2, 8, 10, 11, 8, 12, 8, 14], [2, 'ST', 'Striker 2', '[]', 3, 2, 2, 2, 2, 9, 10, 11, 10, 13, 8, 14], [3, 'MF', 'Fielder 1', '[]', 2, 2, 2, 6, 6, 10, 10, 9, 14, 10, 9, 10], [4, 'MF', 'Fielder 2', '[]', 2, 2, 2, 6, 6, 10, 10, 8, 10, 10, 8, 10], [5, 'MF', 'Fielder 3', '[]', 3, 2, 2, 5, 6, 11, 10, 9, 10, 9, 7, 10], [6, 'DB', 'Back 1', '[]', 2, 2, 2, 10, 10, 7, 8, 6, 7, 6, 4, 5], [7, 'DB', 'Back 2', '[]', 2, 2, 2, 10, 10, 6, 8, 6, 7, 6, 4, 5], [8, 'DB', 'Back 3', '[]', 2, 2, 2, 10, 10, 7, 9, 6, 7, 6, 4, 5], [9, 'GK', 'Keeper 1', '[]', 10, 10, 10, 4, 4, 4, 4, 4, 4, 5, 4, 4]]
728. [[10, 'ST', 'Striker A', '[]', 2, 1, 2, 1, 1, 8, 12, 10, 10, 7, 9, 16], [11, 'ST', 'Striker B', '[]', 2, 2, 2, 1, 1, 7, 11, 11, 8, 11, 9, 11], [12, 'ST', 'Striker C', '[]', 2, 2, 2, 1, 1, 7, 11, 10, 9, 14, 8, 14], [13, 'MF', 'Fielder A', '[]', 2, 2, 2, 6, 6, 9, 8, 8, 10, 3, 9, 8], [14, 'MF', 'Fielder C', '[]', 2, 2, 2, 6, 6, 10, 9, 8, 7, 3, 8, 8], [15, 'DB', 'Back A', '[]', 2, 2, 2, 9, 9, 6, 7, 6, 8, 3, 8, 3], [16, 'DB', 'Back B', '[]', 2, 2, 2, 9, 9, 5, 9, 5, 8, 3, 7, 3], [17, 'DB', 'Back C', '[]', 2, 2, 2, 9, 9, 5, 7, 6, 9, 4, 8, 3], [18, 'GK', 'Keeper A', '[‘Distributor’]', 8, 9, 9, 4, 3, 5, 4, 5, 4, 4, 4, 4]]
729. The first half will be 15 minutes and feature 3 minutes and 17 seconds of extra time
730. KICKOFF
731. 15:00 And there's the kickoff, with Fielder 1 takes possession
732. Shot taken by Fielder 1 and it's on target.
733. CONTINUE
734. KICKOFF
735. 14:44 And there's the kickoff, with Fielder A takes possession
736. Fielder A on the ball with Fielder 2 defending.
737. Shot taken by Fielder A but it's off-target.
738. Keeper Keeper 1 launches the ball over his teammates where it's easily collected by Back C
739. Back C on the ball with Striker 2 defending.
740. Back C on the ball with Striker 1 defending.
741. Back C on the ball with Striker 2 defending.
742. Back C on the ball with Striker 1 defending.
743. Back C on the ball with Striker 1 defending.
744. Back C on the ball with Striker 1 defending.
745. Back C on the ball with Striker 2 defending.
746. Back C on the ball with Striker 2 defending.
747. Back C on the ball with Striker 1 defending.
748. Back C on the ball with Striker 2 defending.
749. Back C on the ball with Striker 1 defending.
750. Back C on the ball with Striker 2 defending.
751. Shot taken by Back C but it's off-target.
752. Keeper Keeper 1 rolls the ball to his defender Back 2
753. Back 2 on the ball with Striker A defending.
754. Back 2 on the ball with Striker C defending.
755. Shot taken by Back 2 but it's off-target.
756. Keeper Keeper A boots the ball into the midfield where it's collected by Fielder A
757. Fielder A on the ball with Fielder 3 defending.
758. Fielder A on the ball with Fielder 3 defending.
759. Fielder A on the ball with Fielder 1 defending.
760. Fielder A on the ball with Fielder 1 defending.
761. Shot taken by Fielder A and it's on target.
762. CONTINUE
763. KICKOFF
764. 11:14 And there's the kickoff, with Fielder 1 takes possession
765. Fielder 1 on the ball with Back B defending.
766. Shot taken by Fielder 1 but it's off-target.
767. Keeper Keeper A pushes the ball deep into the attack and it connects to Striker B
768. Striker B on the ball with Back 2 defending.
769. Shot taken by Striker B but it's off-target.
770. Keeper Keeper 1 launches the ball over his teammates where it's easily collected by Back B
771. Back B on the ball with Striker 2 defending.
772. Back B on the ball with Striker 2 defending.
773. Back B on the ball with Striker 1 defending.
774. Shot taken by Back B and it's on target.
775. CONTINUE
776. KICKOFF
777. 9:51 And there's the kickoff, with Fielder 1 takes possession
778. Fielder 1 on the ball with Back B defending.
779. Fielder 1 on the ball with Back B defending.
780. Shot taken by Fielder 1 but it's off-target.
781. Keeper Keeper A rolls the ball to his defender Back A
782. Back A on the ball with Fielder 2 defending.
783. Back A on the ball with Fielder 2 defending.
784. Back A on the ball with Fielder 1 defending.
785. Back A on the ball with Fielder 1 defending.
786. Back A on the ball with Fielder 1 defending.
787. Back A on the ball with Fielder 1 defending.
788. Back A on the ball with Fielder 2 defending.
789. Back A on the ball with Fielder 2 defending.
790. Back A on the ball with Fielder 2 defending.
791. Back A on the ball with Fielder 2 defending.
792. Back A on the ball with Fielder 2 defending.
793. Back A on the ball with Fielder 2 defending.
794. Back A on the ball with Fielder 3 defending.
795. Back A on the ball with Fielder 3 defending.
796. Back A on the ball with Fielder 3 defending.
797. Back A on the ball with Fielder 3 defending.
798. Back A on the ball with Fielder 2 defending.
799. Back A on the ball with Fielder 1 defending.
800. Back A on the ball with Fielder 3 defending.
801. Shot taken by Back A and it's on target.
802. CONTINUE
803. KICKOFF
804. 5:58 And there's the kickoff, with Fielder 1 takes possession
805. Shot taken by Fielder 1 but it's off-target.
806. Keeper Keeper A launches the ball over his teammates where it's easily collected by Back 1
807. Back 1 on the ball with Striker C defending.
808. Back 1 on the ball with Striker C defending.
809. Shot taken by Back 1 but it's off-target.
810. Keeper Keeper A pushes the ball deep into the attack and it connects to Striker B
811. Striker B on the ball with Back 1 defending.
812. Striker B on the ball with Back 3 defending.
813. Shot taken by Striker B but it's off-target.
814. Keeper Keeper 1 launches the ball over his teammates where it's easily collected by Back A
815. Back A on the ball with Fielder 1 defending.
816. Back A on the ball with Fielder 3 defending.
817. Back A on the ball with Fielder 1 defending.
818. Back A on the ball with Fielder 1 defending.
819. Back A on the ball with Fielder 3 defending.
820. Back A on the ball with Fielder 3 defending.
821. Back A on the ball with Fielder 2 defending.
822. Shot taken by Back A but it's off-target.
823. Keeper Keeper 1 rolls the ball to his defender Back 1
824. Back 1 on the ball with Striker C defending.
825. Shot taken by Back 1 but it's off-target.
826. Keeper Keeper A boots the ball into the midfield where it's collected by Fielder C
827. Fielder C on the ball with Fielder 3 defending.
828. Fielder C on the ball with Fielder 3 defending.
829. Fielder C on the ball with Fielder 1 defending.
830. Shot taken by Fielder C but it's off-target.
831. Keeper Keeper 1 launches the ball over his teammates where it's easily collected by Back C
832. Back C on the ball with Striker 1 defending.
833. Back C on the ball with Striker 2 defending.
834. Back C on the ball with Striker 1 defending.
835. Back C on the ball with Striker 1 defending.
836. Back C on the ball with Striker 1 defending.
837. Back C on the ball with Striker 1 defending.
838. Back C on the ball with Striker 2 defending.
839. Back C on the ball with Striker 1 defending.
840. Back C on the ball with Striker 2 defending.
841. Back C on the ball with Striker 2 defending.
842. Back C on the ball with Striker 2 defending.
843. Back C on the ball with Striker 1 defending.
844. Back C on the ball with Striker 2 defending.
845. Back C on the ball with Striker 2 defending.
846. Back C on the ball with Striker 1 defending.
847. Back C on the ball with Striker 2 defending.
848. Back C on the ball with Striker 1 defending.
849. Back C on the ball with Striker 2 defending.
850. Back C on the ball with Striker 2 defending.
851. Back C on the ball with Striker 1 defending.
852. Back C on the ball with Striker 1 defending.
853. Shot taken by Back C but it's off-target.
854. Keeper Keeper 1 boots the ball into the midfield where it's collected by Fielder 1
855. Fielder 1 on the ball with Back C defending.
856. Shot taken by Fielder 1 but it's off-target.
857. Keeper Keeper A boots the ball into the midfield, but it's stolen by Fielder 3
858. Fielder 3 on the ball with Fielder C defending.
859. Fielder 3 on the ball with Fielder C defending.
860. Shot taken by Fielder 3 but it's off-target.
861. Keeper Keeper A pushes the ball deep into the attack and it connects to Striker C
862. Striker C on the ball with Back 2 defending.
863. Striker C on the ball with Back 3 defending.
864. Shot taken by Striker C but it's off-target.
865. Keeper Keeper 1 launches the ball over his teammates where it's easily collected by Back A
866. Back A on the ball with Fielder 3 defending.
867. Back A on the ball with Fielder 2 defending.
868. Back A on the ball with Fielder 1 defending.
869. Shot taken by Back A but it's off-target.
870. Keeper Keeper 1 rolls the ball to his defender Back 3
871. Back 3 on the ball with Striker C defending.
872. Back 3 on the ball with Striker C defending.
873. Back 3 on the ball with Striker B defending.
874. Back 3 on the ball with Striker C defending.
RAW Paste Data