Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

aiSortData.py 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. from bge import logic
  2. printDebug = True #Set to True to see some basic debug info
  3. cont = logic.getCurrentController()
  4. own = cont.owner
  5. gameName = "shuvit" #Set this to the name of your game!
  6. path = logic.expandPath(own["filePath"])
  7. positionList = []
  8. orientationList = []
  9. scaleList = []
  10. colorList = []
  11. stateList = []
  12. visibilityList = []
  13. skaterAnimList = []
  14. skaterAnimFList = []
  15. deckAnimList = []
  16. deckAnimFList = []
  17. srollVolList = []
  18. srollPitchList = []
  19. sgrind_cementVolList = []
  20. sgrind_cementPitchList = []
  21. sgrind_railVolList = []
  22. sgrind_railPitchList = []
  23. spopsoundList = []
  24. slandsoundList = []
  25. sdeckvisList = []
  26. positiontdList = []
  27. orientationtdList = []
  28. srevertsoundList = []
  29. allDataList = []
  30. allDataPath = path+ own['npc_replay_name']
  31. class readData:
  32. def loadAll(own):
  33. #
  34. # global allDataList
  35. # global positionList
  36. # global orientationList
  37. # global scaleList
  38. # global colorList
  39. # global stateList
  40. # global visibilityList
  41. # global skaterAnimList
  42. # global skaterAnimFList
  43. # global deckAnimList
  44. # global deckAnimFList
  45. # global srollVolList
  46. # global srollPitchList
  47. # global sgrind_cementVolList
  48. # global sgrind_cementPitchList
  49. # global sgrind_railVolList
  50. # global sgrind_railPitchList
  51. # global spopsoundList
  52. # global slandsoundList
  53. # global sdeckvisList
  54. # global positiontdList
  55. # global orientationtdList
  56. # global srevertsoundList
  57. # own['allDataList'] = []
  58. # own['positionList'] = []
  59. # own['orientationList'] = []
  60. # own['scaleList'] = []
  61. # own['colorList'] = []
  62. # own['stateList'] = []
  63. # own['visibilityList'] = []
  64. # own['skaterAnimList'] = []
  65. # own['skaterAnimFList'] = []
  66. # own['deckAnimList'] = []
  67. # own['deckAnimFList'] = []
  68. # own['srollVolList'] = []
  69. # own['srollPitchList'] = []
  70. # own['sgrind_cementVolList'] = []
  71. # own['sgrind_cementPitchList'] = []
  72. # own['sgrind_railVolList'] = []
  73. # own['sgrind_railPitchList'] = []
  74. # own['spopsoundList'] = []
  75. # own['slandsoundList'] = []
  76. # own['sdeckvisList'] = []
  77. # own['positiontdList'] = []
  78. # own['orientationtdList'] = []
  79. # own['srevertsoundList'] = []
  80. allDataPath = path+ own['npc_replay_name']
  81. #if not allDataList:
  82. if own['inited'] == False:
  83. #own['inited'] = True
  84. try:
  85. with open(allDataPath) as all:
  86. data = all.read()
  87. all.close()
  88. allDataList = data.split("|",22)#6)
  89. own['allDataList'] = allDataList
  90. loadedGameName = str(allDataList[0].split("=",1)[1]).strip()
  91. #skaterAnimList = allDataList[7].split()
  92. #skaterAnimFList = allDataList[8].split()
  93. try:
  94. if loadedGameName == gameName:
  95. # positionList = allDataList[1].split()
  96. # orientationList = allDataList[2].split()
  97. # scaleList = allDataList[3].split()
  98. # colorList = allDataList[4].split()
  99. # stateList = allDataList[5].split()
  100. # visibilityList = allDataList[6].split()
  101. # skaterAnimList = allDataList[7].split()
  102. # skaterAnimFList = allDataList[8].split()
  103. # deckAnimList = allDataList[9].split()
  104. # deckAnimFList = allDataList[10].split()
  105. # srollVolList = allDataList[11].split()
  106. # srollPitchList = allDataList[12].split()
  107. # sgrind_cementVolList = allDataList[13].split()
  108. # sgrind_cementPitchList = allDataList[14].split()
  109. # sgrind_railVolList = allDataList[15].split()
  110. # sgrind_railPitchList = allDataList[16].split()
  111. # spopsoundList = allDataList[17].split()
  112. # slandsoundList = allDataList[18].split()
  113. # sdeckvisList = allDataList[19].split()
  114. # positiontdList = allDataList[20].split()
  115. # orientationtdList = allDataList[21].split()
  116. # srevertsoundList = allDataList[22].split()
  117. #
  118. own['positionList'] = allDataList[1].split()
  119. own['orientationList'] = allDataList[2].split()
  120. own['scaleList'] = allDataList[3].split()
  121. own['colorList'] = allDataList[4].split()
  122. own['stateList'] = allDataList[5].split()
  123. own['visibilityList'] = allDataList[6].split()
  124. own['skaterAnimList'] = allDataList[7].split()
  125. own['skaterAnimFList'] = allDataList[8].split()
  126. own['deckAnimList'] = allDataList[9].split()
  127. own['deckAnimFList'] = allDataList[10].split()
  128. own['srollVolList'] = allDataList[11].split()
  129. own['srollPitchList'] = allDataList[12].split()
  130. own['sgrind_cementVolList'] = allDataList[13].split()
  131. own['sgrind_cementPitchList'] = allDataList[14].split()
  132. own['sgrind_railVolList'] = allDataList[15].split()
  133. own['sgrind_railPitchList'] = allDataList[16].split()
  134. own['spopsoundList'] = allDataList[17].split()
  135. own['slandsoundList'] = allDataList[18].split()
  136. own['sdeckvisList'] = allDataList[19].split()
  137. own['positiontdList'] = allDataList[20].split()
  138. own['orientationtdList'] = allDataList[21].split()
  139. own['srevertsoundList'] = allDataList[22].split()
  140. positionList = own['positionList'
  141. ]
  142. orientationList = own['orientationList']
  143. scaleList = own['scaleList']
  144. colorList = own['colorList']
  145. stateList = own['stateList']
  146. visibilityList = own['visibilityList']
  147. skaterAnimList = own['skaterAnimList']
  148. skaterAnimFList = own['skaterAnimFList']
  149. deckAnimList = own['deckAnimList']
  150. deckAnimFList = own['deckAnimFList']
  151. srollVolList = own['srollVolList']
  152. srollPitchList = own['srollPitchList']
  153. sgrind_cementVolList = own['sgrind_cementVolList']
  154. sgrind_cementPitchList = own['sgrind_cementPitchList']
  155. sgrind_railVolList = own['sgrind_railVolList']
  156. sgrind_railPitchList = own['sgrind_railPitchList']
  157. spopsoundList = own['spopsoundList']
  158. slandsoundList = own['slandsoundList']
  159. sdeckvisList = own['sdeckvisList']
  160. positiontdList = own['positiontdList']
  161. orientationtdList = own['orientationtdList']
  162. srevertsoundList = own['srevertsoundList']
  163. if printDebug:
  164. print("Read file "+allDataPath)
  165. own['inited'] = True
  166. except:
  167. print("error reading replay data")
  168. except IOError:
  169. if printDebug:
  170. print("Error reading "+allDataPath)
  171. def returnPosition(objIndex, valueIndex, own):
  172. positionList = own['positionList']
  173. if positionList:
  174. name = positionList[objIndex-2] #That -2 is a little workaround to a list index out of range error.
  175. position = positionList[valueIndex-2]
  176. name = name.replace(" ","")
  177. #print(position)
  178. position = str(position)
  179. position = position.replace(","," ")
  180. pX = float(position.split()[0])
  181. pY = float(position.split()[1])
  182. pZ = float(position.split()[2])
  183. position = [pX,pY,pZ]
  184. #print(name, position)
  185. return(name, position)
  186. def returnOrientation(objIndex, valueIndex, own):
  187. orientationList = own['orientationList']
  188. if orientationList:
  189. name = orientationList[objIndex-2]
  190. orientation = orientationList[valueIndex-2]
  191. name = name.replace(" ","")
  192. orientation = str(orientation)
  193. orientation = orientation.replace(","," ")
  194. orientation = orientation.split()
  195. return(name, orientation)
  196. def returnScale(objIndex, valueIndex):
  197. if scaleList:
  198. name = scaleList[objIndex-2]
  199. scale = scaleList[valueIndex-2]
  200. name = name.replace(" ","")
  201. scale = str(scale)
  202. scale = scale.replace(","," ")
  203. sX = float(scale.split()[0])
  204. sY = float(scale.split()[1])
  205. sZ = float(scale.split()[2])
  206. scale = [sX,sY,sZ]
  207. return(name, scale)
  208. def returnColor(objIndex, valueIndex):
  209. if colorList:
  210. name = colorList[objIndex-2]
  211. color = colorList[valueIndex-2]
  212. name = name.replace(" ","")
  213. color = str(color)
  214. color = color.replace(","," ")
  215. cR = float(color.split()[0])
  216. cG = float(color.split()[1])
  217. cB = float(color.split()[2])
  218. cA = float(color.split()[3])
  219. color = [cR,cG,cB,cA]
  220. return(name, color)
  221. def returnState(objIndex, valueIndex):
  222. if stateList:
  223. name = stateList[objIndex-2]
  224. state = stateList[valueIndex-2]
  225. name = name.replace(" ","")
  226. state = str(state)
  227. state = state.replace(","," ")
  228. state = int(state)
  229. return(name, state)
  230. def returnVisibility(objIndex, valueIndex):
  231. if visibilityList:
  232. name = visibilityList[objIndex-2]
  233. visible = visibilityList[valueIndex-2]
  234. name = name.replace(" ","")
  235. visible = str(visible)
  236. visible = visible.replace(","," ")
  237. return(name, visible)
  238. def returnSkaterAnim(objIndex, valueIndex, own):
  239. #print('getting anim list')
  240. #print(objIndex-2)
  241. skaterAnimList = own['skaterAnimList']
  242. #print(skaterAnimList)
  243. if skaterAnimList:
  244. name = skaterAnimList[objIndex-2]
  245. skaterAnim = skaterAnimList[valueIndex-2]
  246. name = name.replace(" ","")
  247. skaterAnim = str(skaterAnim)
  248. skaterAnim = skaterAnim.replace(","," ")
  249. if skaterAnim == 'control_cube.002':
  250. skaterAnim = skaterAnimList[valueIndex-3]
  251. name = name.replace(" ","")
  252. skaterAnim = str(skaterAnim)
  253. skaterAnim = skaterAnim.replace(","," ")
  254. #print(skaterAnim, (objIndex-2), (valueIndex-2))
  255. #print(skaterAnimList)
  256. return(name, skaterAnim)
  257. def returnSkaterAnimF(objIndex, valueIndex, own):
  258. skaterAnimFList = own['skaterAnimFList']
  259. if skaterAnimFList:
  260. name = skaterAnimFList[objIndex-2]
  261. skaterAnimF = skaterAnimFList[valueIndex-2]
  262. name = name.replace(" ","")
  263. skaterAnimF = str(skaterAnimF)
  264. skaterAnimF = skaterAnimF.replace(","," ")
  265. #print('sOi', objIndex, 'sVi', valueIndex)
  266. return(name, skaterAnimF)
  267. def returnDeckAnim(objIndex, valueIndex, own):
  268. #print(objIndex-2)
  269. deckAnimList = own['deckAnimList']
  270. if deckAnimList:
  271. name = deckAnimList[objIndex-2]
  272. deckAnim = deckAnimList[valueIndex-2]
  273. name = name.replace(" ","")
  274. deckAnim = str(deckAnim)
  275. deckAnim = deckAnim.replace(","," ")
  276. if deckAnim == 'control_cube.002':
  277. deckAnim = deckAnimList[valueIndex-3]
  278. name = name.replace(" ","")
  279. deckAnim = str(deckAnim)
  280. deckAnim = deckAnim.replace(","," ")
  281. #print(deckAnim, (objIndex-2), (valueIndex-2))
  282. #print('dOi', objIndex, 'dVi', valueIndex)
  283. return(name, deckAnim)
  284. def returnDeckAnimF(objIndex, valueIndex, own):
  285. deckAnimFList = own['deckAnimFList']
  286. if deckAnimFList:
  287. name = deckAnimFList[objIndex-2]
  288. deckAnimF = deckAnimFList[valueIndex-2]
  289. name = name.replace(" ","")
  290. deckAnimF = str(deckAnimF)
  291. deckAnimF = deckAnimF.replace(","," ")
  292. return(name, deckAnimF)
  293. ###
  294. def returnSrollVol(objIndex, valueIndex):
  295. if srollVolList:
  296. name = srollVolList[objIndex-2]
  297. srollVol = srollVolList[valueIndex-2]
  298. name = name.replace(" ","")
  299. srollVol = str(srollVol)
  300. srollVol = srollVol.replace(","," ")
  301. srollVol = float(srollVol)
  302. return(name, srollVol)
  303. def returnSrollPitch(objIndex, valueIndex):
  304. if srollPitchList:
  305. name = srollPitchList[objIndex-2]
  306. srollPitch = srollPitchList[valueIndex-2]
  307. name = name.replace(" ","")
  308. srollPitch = str(srollPitch)
  309. srollPitch = srollPitch.replace(","," ")
  310. srollPitch = float(srollPitch)
  311. return(name, srollPitch) ####
  312. ###
  313. def returnSgrind_cementVol(objIndex, valueIndex):
  314. if sgrind_cementVolList:
  315. name = sgrind_cementVolList[objIndex-2]
  316. sgrind_cementVol = sgrind_cementVolList[valueIndex-2]
  317. name = name.replace(" ","")
  318. sgrind_cementVol = str(sgrind_cementVol)
  319. sgrind_cementVol = sgrind_cementVol.replace(","," ")
  320. sgrind_cementVol = float(sgrind_cementVol)
  321. return(name, sgrind_cementVol)
  322. def returnSgrind_cementPitch(objIndex, valueIndex):
  323. if sgrind_cementPitchList:
  324. name = sgrind_cementPitchList[objIndex-2]
  325. sgrind_cementPitch = sgrind_cementPitchList[valueIndex-2]
  326. name = name.replace(" ","")
  327. sgrind_cementPitch = str(sgrind_cementPitch)
  328. sgrind_cementPitch = sgrind_cementPitch.replace(","," ")
  329. sgrind_cementPitch = float(sgrind_cementPitch)
  330. return(name, sgrind_cementPitch) ####
  331. ###
  332. def returnSgrind_railVol(objIndex, valueIndex):
  333. if sgrind_railVolList:
  334. name = sgrind_railVolList[objIndex-2]
  335. sgrind_railVol = sgrind_railVolList[valueIndex-2]
  336. name = name.replace(" ","")
  337. sgrind_railVol = str(sgrind_railVol)
  338. sgrind_railVol = sgrind_railVol.replace(","," ")
  339. sgrind_railVol = float(sgrind_railVol)
  340. return(name, sgrind_railVol)
  341. def returnSgrind_railPitch(objIndex, valueIndex):
  342. if sgrind_railPitchList:
  343. name = sgrind_railPitchList[objIndex-2]
  344. sgrind_railPitch = sgrind_railPitchList[valueIndex-2]
  345. name = name.replace(" ","")
  346. sgrind_railPitch = str(sgrind_railPitch)
  347. sgrind_railPitch = sgrind_railPitch.replace(","," ")
  348. sgrind_railPitch = float(sgrind_railPitch)
  349. return(name, sgrind_railPitch) ####
  350. def returnSpopsound(objIndex, valueIndex):
  351. if spopsoundList:
  352. name = spopsoundList[objIndex-2]
  353. spopsound = spopsoundList[valueIndex-2]
  354. name = name.replace(" ","")
  355. spopsound = str(spopsound)
  356. spopsound = spopsound.replace(","," ")
  357. spopsound = int(spopsound)
  358. return(name, spopsound)
  359. def returnSlandsound(objIndex, valueIndex):
  360. if slandsoundList:
  361. name = slandsoundList[objIndex-2]
  362. slandsound = slandsoundList[valueIndex-2]
  363. name = name.replace(" ","")
  364. slandsound = str(slandsound)
  365. slandsound = slandsound.replace(","," ")
  366. slandsound = int(slandsound)
  367. return(name, slandsound)
  368. def returnSdeckvis(objIndex, valueIndex):
  369. if sdeckvisList:
  370. name = sdeckvisList[objIndex-2]
  371. sdeckvis = sdeckvisList[valueIndex-2]
  372. name = name.replace(" ","")
  373. sdeckvis = str(sdeckvis)
  374. sdeckvis = sdeckvis.replace(","," ")
  375. sdeckvis = int(sdeckvis)
  376. return(name, sdeckvis)
  377. def returntdPosition(objIndex, valueIndex):
  378. if positiontdList:
  379. name = positiontdList[objIndex-2] #That -2 is a little workaround to a list index out of range error.
  380. position = positiontdList[valueIndex-2]
  381. name = name.replace(" ","")
  382. position = str(position)
  383. position = position.replace(","," ")
  384. pX = float(position.split()[0])
  385. pY = float(position.split()[1])
  386. pZ = float(position.split()[2])
  387. position = [pX,pY,pZ]
  388. return(name, position)
  389. def returntdOrientation(objIndex, valueIndex):
  390. if orientationtdList:
  391. name = orientationtdList[objIndex-2]
  392. orientation = orientationtdList[valueIndex-2]
  393. name = name.replace(" ","")
  394. orientation = str(orientation)
  395. orientation = orientation.replace(","," ")
  396. orientation = orientation.split()
  397. return(name, orientation)
  398. def returnSrevertsound(objIndex, valueIndex):
  399. if srevertsoundList:
  400. name = srevertsoundList[objIndex-2]
  401. srevertsound = srevertsoundList[valueIndex-2]
  402. name = name.replace(" ","")
  403. srevertsound = str(srevertsound)
  404. srevertsound = srevertsound.replace(","," ")
  405. srevertsound = int(srevertsound)
  406. return(name, srevertsound)
  407. ###
  408. def getLengthPos(own):
  409. positionList = own['positionList']
  410. if positionList:
  411. return(len(positionList))
  412. def getLengthOri(own):
  413. orientationList = own['orientationList']
  414. if orientationList:
  415. return(len(orientationList))
  416. def getLengthSca():
  417. if scaleList:
  418. return(len(scaleList))
  419. def getLengthCol():
  420. if colorList:
  421. return(len(colorList))
  422. def getLengthSta():
  423. if stateList:
  424. return(len(stateList))
  425. def getLengthVis():
  426. if visibilityList:
  427. return(len(visibilityList))
  428. def getLengthSkaterAnim(own):
  429. skaterAnimList = own['skaterAnimList']
  430. if skaterAnimList:
  431. return(len(skaterAnimList))
  432. def getLengthSkaterAnimF(own):
  433. skaterAnimFList = own['skaterAnimFList']
  434. if skaterAnimFList:
  435. return(len(skaterAnimFList))
  436. def getLengthDeckAnim(own):
  437. deckAnimList = own['deckAnimList']
  438. if deckAnimList:
  439. return(len(deckAnimList))
  440. def getLengthDeckAnimF(own):
  441. deckAnimFList = own['deckAnimFList']
  442. if deckAnimFList:
  443. #print(len(deckAnimFList), 'deckanimflisht')
  444. return(len(deckAnimFList))
  445. def getLengthSrollVol():
  446. if srollVolList:
  447. return(len(srollVolList))
  448. def getLengthSrollPitch():
  449. if srollPitchList:
  450. return(len(srollPitchList))
  451. def getLengthSgrind_cementVol():
  452. if sgrind_cementVolList:
  453. return(len(sgrind_cementVolList))
  454. def getLengthSgrind_cementPitch():
  455. if sgrind_cementPitchList:
  456. return(len(sgrind_cementPitchList))
  457. def getLengthSgrind_railVol():
  458. if sgrind_railVolList:
  459. return(len(sgrind_railVolList))
  460. def getLengthSgrind_railPitch():
  461. if sgrind_railPitchList:
  462. return(len(sgrind_railPitchList))
  463. def getLengthSpopsound():
  464. if spopsoundList:
  465. return(len(spopsoundList))
  466. def getLengthSlandsound():
  467. if slandsoundList:
  468. return(len(slandsoundList))
  469. def getLengthSdeckvis():
  470. if sdeckvisList:
  471. return(len(sdeckvisList))
  472. def getLengthtdPos():
  473. if positiontdList:
  474. return(len(positiontdList))
  475. def getLengthtdOri():
  476. if orientationtdList:
  477. return(len(orientationtdList))
  478. def getLengthSrevertsound():
  479. if srevertsoundList:
  480. return(len(srevertsoundList))