-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlayerMovement.py
51 lines (45 loc) · 1.25 KB
/
PlayerMovement.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
from BaseCode.Game import Game
from BaseCode.Cycle import GameMode
import matplotlib.pyplot as plt
import sys
import os
def read_log(path):
g = Game.read_log(path)
moves = [0 for i in range(12)]
for p in range(1, 12):
last_pos = None
move = 0
for c in g.cycles():
if c.game_mode() != GameMode.play_on:
last_pos = None
else:
if last_pos:
move += c.players()[p].pos_().dist(last_pos)
last_pos = c.players()[p].pos_()
moves[p] = move
return moves
def main(path):
"""
Showing player move point by plot
:param path: path of rcg files
"""
import multiprocessing
process_pool = multiprocessing.Pool(processes=30)
files = []
for f in os.listdir(path)[:]:
if f.endswith('.rcg'):
files.append(os.path.join(path, f))
result_list = process_pool.map(read_log, files)
moves = [0 for i in range(12)]
for r in result_list:
for i in range(12):
moves[i] += r[i]
for i in range(12):
moves[i] /= len(files)
print(moves)
print(sum(moves))
if __name__ == "__main__":
path = 'Data'
if len(sys.argv) > 1:
path = sys.argv[1]
main(path)