forked from Delaunay/dota2env
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMilestones
More file actions
380 lines (297 loc) · 8.32 KB
/
Copy pathMilestones
File metadata and controls
380 lines (297 loc) · 8.32 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# The Game
From OpenAI
* 30 FPS (~0.033 s per frame)
* 45 Minutes
* Every 4 Frame (~0.133 s per decision, 450 actions per minute)
* Reaction Time is 0.266 seconds
* 20300 steps
1. Observe 4 Frames
2. Use 4 Frames to decide action
3. Take action in the nect 4 Frames
1. The action space (Appendix F)
Allows the player to change the game state in order to increase the probability of winning overtime
2. The observed game state (Appendix E)
Allows the player to observe the current game in order to make a decision
3. Objective Function (Appendix G)
Rewards the player for an action increasing its probability of winning
## The Action Space
Filter the action space to present a set of actions to choose from
* Abilities (4+)
* 6 Items
* Aghs
* Shard
* 1 Neutral Item
* 1 TP
* Attack
* Move
* Cancel
* Purchase
* buyback
* take outpost
* courier shield
* courier speed burst
3 Action Parameters
* 4 Dim Frame Delay (useless)
* Unit Selection 189 dim (189 = 5 + 5 + 15 + 2 * 82)
* Offset (position in a 9x9 square)
* Action Type
* No Target
* Point Target
* Unit Target
* Unit Offset Target
* Teleport Target
* Ward Target
## The Game State
> 1,200 categorical values and 14,534 continuous/boolean values.
* Global
* Time Since Game start
* is_day
* Time until next day or Night
* Time until next Soldier Spawn
* Time until next bounty Spawn
* Time until next runes Spawn
* Time until next Neutral Spawn
* Time since seen Courrier
* Roshan Current Max HP
* is_roshan_alive
* is_roshan_dead
* does_roshan_drop_cheese
* does_roshan_drop_refresher
* Glyph Cooldown Radiant
* Glyph Cooldown Dire
* Item Stock Count
* Gem
* Smoke
* Wards
* Infused RainDrops
* Agh Shard
* Units: 189 (5 heroes, 30 creeps, 21 buildings, 30 wards, 5 couriers)
* position.x
* position.y
* position.z
* angle.cos
* angle.sin
* is_attacking
* time_since_last_attack
* max_health
* heath_[t-16:now]
* attack damage
* attack speed
* physical resistance
* invulnerable due to glyph
* glyph timer
* movement speed
* is_allied
* is_neutral
* animation cycle time
* ETA of incoming projectile
* vector to me dx [e]
* vector to me dy [e]
* vector to me dz [e]
* am_I_attacking_it [e]
* is_it_attacking_me [e]
* ETA of projectile from unit to me [e]
* unit type
* current animation
* Heroes (10)
* is_alive
* death_count
* hero_in_sight
* hero_last_seen
* hero_teleporting
* teleport_target.x
* teleport_target.y
* teleport_channel_time
* respawn_time
* current_gold
* level
* mana_max
* mana_current
* mana_regen
* health_regen
* magic_resistance
* strength
* agi
* intel
* invisible
* is_using_ability
* is_allied
* is_enemy
* is_creep
* is_hero
* buyback_available
* buyback_cooldown
* buyback_cost
* empty_backpack_slots
* empty_inventory_slots
* lane assignment.top
* lane assignment.mid
* lane assignment.bot
* nearby_terrain (14x14 grid)
* Nearby Map (8x8) [e]
* elevation
* passable
* allied creep density
* enemy creep density
* area of effect
* spells in effect
* Previously Sampled Action 310 [e]
* Offset (3x2x9)
* Unit Target Embedding (128)
* Primary Action Embedding (128)
* Hero Modifiers (10 x 10)
* remaining_duration
* stack_count
* modifier_name
* Item Modifiers (10 x 16)
* location.inventory
* location.backpack
* location.stash
* charges
* is_on_cooldown
* cooldown_time
* is_disabled_by_swap
* item_swap_cooldown
* toggled_state
* item_state.str
* item_state.agi
* item_state.int
* item_state.none
* item_name
* Per Abilities (10 x 6)
* cooldown_time
* in_use
* castable
* level1
* level2
* level3
* level4
* Per Pickup (6)
is_there
is_not_there
state_unknown
location.x
location.y
distance_from_hero_0
distance_from_hero_1
distance_from_hero_2
distance_from_hero_3
distance_from_hero_4
distance_from_hero_5
distance_from_hero_6
distance_from_hero_7
distance_from_hero_8
distance_from_hero_9
* Minimap (10x10)
is_visible
allied creeps
enemy creeps
enemy heroes
allied wards
enemy wards
cell.x
cell.y
cell.id ?
* Normalize the data by the running mean and std clip((obs - mean) / std, -5, 5)
## The Objective Function
Hero Reward := (Team Reward + Solo Reward) * 0.6 ^ (T / 10 mins)
Reward := (1 - p) * Solo Reward + p * (Sum of Allied Reward) / 4
Dire Reward := Sum(Reward) - Radiant Reward
Radiant Reward := Sum(Reward) - Dire Reward
Normalize the reward overtime as the ability to farm increase
### Rewards
Name | Reward | Type
--------------------|-----------|-------
Win | 5 | Team
Hero Death | -1 | Solo
Courier Death | -2 | Team
XP Gained | 0.002 | Solo
Gold Gained | 0.006 | Solo
Gold Spent | 0.0006 | Solo
Health Changed | 2 | Solo | %of health = ( x + 1 - (1 - x) ^ 4) / 2
Mana Changed | 0.75 | Solo
Killed Hero | -0.6 | Solo
Last Hit | -0.16 | Solo | Reduce the reward since we already got a bit chunk from exp & gold
Deny | 0.15 | Solo
Gained Aegis | 5 | Team
Ancient HP Change | 5 | Team
Megas Unlocked | 4 | Team
T1 Tower | 2.25 | Team
T2 Tower | 3 | Team
T3 Tower | 4.5 | Team
T4 Tower | 2.25 | Team | 2/3 = building health + 1/3 on destroy
Outpost | 2.25 | Team
Barracks | 6 | Team | 2/3 = building health + 1/3 on destroy
Lane Assign | -0.15 | Solo
# Embeddings
## Unit Target Embedding
Unit Info -> f -> Vector(128) -> F > Unit Info
## Action Embedding
* Primary Action Embedding (128)
## Ability & Item Embedding
We see Item as Ability you can buy/Equip
# The ML Model
The ML model takes a state as input and outputs an action.
The goal is to train the model to make decision that increase its likelyness of winning
Maximize the probability of winning through a reward function.
Reward function is a zero sum game (reward earned by the opposite team diminish the overall reward)
## OpenAI Original Model
* Shared LSTM block of 4096 units
* Connected to separate fully Connected layers
* Final model had 158,502,815 parameters
## Inference Engine
# Optimization processs
* PPO with GAE
* 120 samples, eachwith 16 timestep
* Adam Optimizer with truncated back propagation over 16 timesteps (64 Frames or 2.13 seconds)
# Integration with DOt2 Engine (Appendix K)
Message sent/received to/from a gRPC server that fowards it to LUA which makes the decision
# Transfer learning
int luaopen_genericbot (lua_State* L)
* 5 Ally Heroes
* 5 Enemy Heroes
* 25 buildinds
* 30 creeps
* 30 wards
* 5 couriers
* 15 Neutrals
### Hero State
* Health
* Mana
* Gold
* Experience
* Position
* Abilities (4+)
* 6 Item Slots
* Aghs
* Shard
* 1 Neutral Item
* 1 TP
* Stats
* Attack (Speed, Damage, Range, Spell Amp, Mana Regen)
* Armor (Amror, Phys, Magic, Status, Evasion, Health Regen)
* Move Speed
* Strength
* Agility
* Intelligence
### Non Hero State
* Health
* Mana
Generate GIF
ffmpeg -i luafun_30sec.mp4 -vf "fps=25,scale=320:-1:flags=lanczos" -loop 0 output.gif
def a1(action):
from luafun.game.action import ARG, Action
import luafun.game.constants as const
p1 = action[2][0]
p1[ARG.action] = Action.PurchaseItem
p1[ARG.sItem] = const.get_item('item_tango')
def a2(action):
from luafun.game.action import ARG, Action
p1 = action[2][0]
p1[ARG.action] = Action.MoveToLocation
p1[ARG.vLoc] = [-6016 / 8288, -6784 / 8288]
def a3(action):
from luafun.game.action import ARG, Action
p1 = action[2][0]
p1[ARG.action] = Action.UseAbilityOnTree
p1[ARG.vLoc] = [-6016 / 8288, -6784 / 8288]