-
Notifications
You must be signed in to change notification settings - Fork 0
/
strat.py
149 lines (138 loc) · 5.19 KB
/
strat.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import networkx as nx
import matplotlib.pyplot as plt
from matplotlib import cm
def add_nodes_and_edges(G, dictionary, parent=None):
viridis = cm.get_cmap("viridis", 6)
cmap = viridis.colors[::-1]
for key, value in dictionary.items():
node_label = key
if key.startswith("RvL") or key.startswith("RvR"):
node_color = 0
elif "grip" in key.lower():
node_color = 1
elif "step" in key.lower() or "push" in key.lower() or "pull" in key.lower():
node_color = 2
elif key.startswith("R "):
node_color = 3
elif key.startswith("L "):
node_color = 4
else:
node_color = 5
if parent:
G.add_edge(parent, key)
G.add_node(
key,
label=node_label,
color=cmap[node_color],
size=5000 if node_color in (3, 4) else 2000,
)
if isinstance(value, dict):
add_nodes_and_edges(G, value, key)
stances = [
{
"RvR": {
"Grip fight middle distance": {
"Sleeve grip": {
"Collar grip": {
"Sprint step pull left": {"R Ko-uchi": {}, "R Osoto": {}},
"Pull forwards.": {
"R Sasae": {
"Back step, pull deep sprint step R": {
"R Uchi-mata": {}
}
},
"L Ko-uchi": {
"R Ko-uchi": {"L De-ashi": {}, "R Ippon-seoi": {}},
"R Sasae": {},
},
"R swing Uchi-mata": {},
},
"Push sprint step back": {"R Ko-uchi": {}, "R O-uchi": {}},
"Left twist step forwards": {
"R Koshi-guruma": {},
"R Uchi-mata..": {},
"R Ippon-seoi..": {},
},
},
"Second sleeve grip (elbow)": {
"Pull forwards": {"R Uchi-mata.": {}},
"R Sode": {},
"L Sode": {},
},
"Cross grip": {
"R Osoto": {},
"R Ko-uchi-makikomi": {},
"L Reverse Kata-guruma": {},
},
"Push drive collapse first sleeve grip": {
"Pull forwards..": {"R Ippon-seoi.": {}},
},
},
"Armpit grip": {"Collar grip.": {"R Osoto.": {}}},
},
},
},
{
"RvL": {
"Grip fight middle distance": {
"Collar grip (inside)": {
"Sleeve grip": {
"Shoulder up uke's collar grip": {
"Deep waist grip": {
"R Yagura-nage": {},
"R O-goshi": {},
"R Hane-goshi": {},
},
"Stab step R": {"Back-step L": {"R Uchi-mata": {}}},
"R Ko-soto": {
"Deep back-step L": {
"R swing Harai-goshi": {},
"R swing Tai-otoshi": {},
"R Tani-otoshi": {
"R Ashi-guruma": {},
"R Osoto": {},
},
"R Ura-nage": {},
},
},
"Push sprint step": {
"Back-step L": {
"R Uchi-mata": {},
"R O-uchi": {
"L Harai-tsurikomi-ashi": {
"R Osoto": {"L De-ashi": {}}
}
},
},
"L Ippon-seoi": {},
},
}
}
},
"Collar grip (outside)": {"Collar grip (inside)": {}},
"Double grip near sleeve": {
"Pull in": {"R belt grip": {"R Sumi-gaeshi": {}}}
},
}
}
},
]
for stance in stances:
G = nx.DiGraph()
add_nodes_and_edges(G, stance)
node_colors = [data["color"] for _, data in G.nodes(data=True)]
node_sizes = [data["size"] for _, data in G.nodes(data=True)]
pos = nx.nx_pydot.graphviz_layout(G, prog="dot")
fig = plt.figure(1, figsize=(15, 10)) # , font_size=10
nx.draw(
G,
with_labels=True,
node_color=node_colors,
font_size=8,
node_size=node_sizes,
alpha=0.3,
arrows=True,
pos=pos,
)
plt.title("Strat")
plt.show()