-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlayerMoveDataGen.py
65 lines (55 loc) · 1.81 KB
/
PlayerMoveDataGen.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
from BaseCode.Game import Game
import sys
import os
from BaseCode.Cycle import GameMode
def make_x(cycle, player_unum):
return [cycle.players()[player_unum].pos_().x(), cycle.players()[player_unum].pos_().y()]
def make_y(cycle, player_unum):
return [cycle.players()[player_unum].pos_().x(), cycle.players()[player_unum].pos_().y()]
def make_data_set(cycles, start_end, player):
start = start_end[0]
end = start_end[1]
if end - start < 5:
return None
data_set = []
for i in range(start, end - 3):
X = []
for j in range(i, i + 5):
X += make_x(cycles[j], player)
Y = []
for j in range(i + 5, i + 7):
Y += make_y(cycles[j], player)
data_set.append((X, Y))
print(data_set)
return data_set
def main(path, player, offense):
"""
Showing player move point by plot
:param path: path of rcg files
:param player: number of player [-11, -1] for left team and [1, 11] for right team
"""
data_set = []
for f in os.listdir(path):
g = Game.read_log(os.path.join(path, f))
seq = []
for ic in range(len(g.cycles())):
if g.cycles()[ic].next_kicker_team == offense and g.cycles()[ic].game_mode() == GameMode.play_on:
if len(seq) == 0 or not seq[-1][1] == 0:
seq.append([ic, 0])
else:
if len(seq) > 0 and seq[-1][1] == 0:
seq[-1][1] = ic - 1
print(seq)
for s in seq:
res = make_data_set(g.cycles(), s, player)
if res:
data_set += res
break
if __name__ == "__main__":
path = 'Data'
player = -9
if len(sys.argv) > 1:
path = sys.argv[1]
if len(sys.argv) > 2:
player = int(sys.argv[2])
main(path, player, 'l')