@@ -41,11 +41,57 @@ func NewCastAction(sim *Simulation, sp *Spell) AgentAction {
41
41
}
42
42
}
43
43
44
+ // ################################################################
45
+ // LB ONLY
46
+ // ################################################################
47
+ type LBOnlyAgent struct {
48
+ lb * Spell
49
+ }
50
+
51
+ func (agent * LBOnlyAgent ) ChooseAction (sim * Simulation ) AgentAction {
52
+ return NewCastAction (sim , agent .lb )
53
+ }
54
+
55
+ func (agent * LBOnlyAgent ) OnActionAccepted (sim * Simulation , action AgentAction ) {}
56
+ func (agent * LBOnlyAgent ) Reset (sim * Simulation ) {}
57
+
58
+ func NewLBOnlyAgent (sim * Simulation ) * LBOnlyAgent {
59
+ return & LBOnlyAgent {
60
+ lb : spellmap [MagicIDLB12 ],
61
+ }
62
+ }
63
+
64
+ // ################################################################
65
+ // CL ON CD
66
+ // ################################################################
67
+ type CLOnCDAgent struct {
68
+ lb * Spell
69
+ cl * Spell
70
+ }
71
+
72
+ func (agent * CLOnCDAgent ) ChooseAction (sim * Simulation ) AgentAction {
73
+ if sim .isOnCD (MagicIDCL6 ) {
74
+ return NewCastAction (sim , agent .lb )
75
+ } else {
76
+ return NewCastAction (sim , agent .cl )
77
+ }
78
+ }
79
+
80
+ func (agent * CLOnCDAgent ) OnActionAccepted (sim * Simulation , action AgentAction ) {}
81
+ func (agent * CLOnCDAgent ) Reset (sim * Simulation ) {}
82
+
83
+ func NewCLOnCDAgent (sim * Simulation ) * CLOnCDAgent {
84
+ return & CLOnCDAgent {
85
+ lb : spellmap [MagicIDLB12 ],
86
+ cl : spellmap [MagicIDCL6 ],
87
+ }
88
+ }
89
+
44
90
// ################################################################
45
91
// FIXED ROTATION
46
92
// ################################################################
47
93
type FixedRotationAgent struct {
48
- numLBsPerCL int // If -1, uses LB only
94
+ numLBsPerCL int
49
95
numLBsSinceLastCL int
50
96
lb * Spell
51
97
cl * Spell
@@ -62,10 +108,6 @@ func (agent *FixedRotationAgent) temporaryHasteActive(sim *Simulation) bool {
62
108
}
63
109
64
110
func (agent * FixedRotationAgent ) ChooseAction (sim * Simulation ) AgentAction {
65
- if agent .numLBsPerCL == - 1 {
66
- return NewCastAction (sim , agent .lb )
67
- }
68
-
69
111
if agent .numLBsSinceLastCL < agent .numLBsPerCL {
70
112
return NewCastAction (sim , agent .lb )
71
113
}
@@ -150,8 +192,9 @@ type AdaptiveAgent struct {
150
192
manaSnapshots [manaSnapshotsBufferSize ]ManaSnapshot
151
193
numSnapshots int32
152
194
firstSnapshotIndex int32
153
- lb * Spell
154
- cl * Spell
195
+
196
+ baseAgent Agent // The agent used most of the time
197
+ surplusAgent Agent // The agent used when we have extra mana
155
198
}
156
199
157
200
const manaSpendingWindowNumSeconds = 60
@@ -196,10 +239,6 @@ func (agent *AdaptiveAgent) takeSnapshot(sim *Simulation) {
196
239
}
197
240
198
241
func (agent * AdaptiveAgent ) ChooseAction (sim * Simulation ) AgentAction {
199
- if sim .isOnCD (MagicIDCL6 ) {
200
- return NewCastAction (sim , agent .lb )
201
- }
202
-
203
242
agent .purgeExpiredSnapshots (sim )
204
243
oldestSnapshot := agent .getOldestSnapshot ()
205
244
@@ -217,28 +256,47 @@ func (agent *AdaptiveAgent) ChooseAction(sim *Simulation) AgentAction {
217
256
sim .Debug ("[AI] CL Ready: Mana/s: %0.1f, Est Mana Cost: %0.1f, CurrentMana: %0.1f\n " , manaSpendingRate , projectedManaCost , sim .CurrentMana )
218
257
}
219
258
220
- // If we have enough mana to burn and CL is off CD , use it .
259
+ // If we have enough mana to burn, use the surplus agent .
221
260
if projectedManaCost < sim .CurrentMana {
222
- return NewCastAction (sim , agent .cl )
261
+ return agent .surplusAgent .ChooseAction (sim )
262
+ } else {
263
+ return agent .baseAgent .ChooseAction (sim )
223
264
}
224
-
225
- return NewCastAction (sim , agent .lb )
226
265
}
227
266
func (agent * AdaptiveAgent ) OnActionAccepted (sim * Simulation , action AgentAction ) {
228
267
agent .takeSnapshot (sim )
268
+ agent .baseAgent .OnActionAccepted (sim , action )
269
+ agent .surplusAgent .OnActionAccepted (sim , action )
229
270
}
230
271
231
272
func (agent * AdaptiveAgent ) Reset (sim * Simulation ) {
232
273
agent .manaSnapshots = [manaSnapshotsBufferSize ]ManaSnapshot {}
233
274
agent .firstSnapshotIndex = 0
234
275
agent .numSnapshots = 0
276
+ agent .baseAgent .Reset (sim )
277
+ agent .surplusAgent .Reset (sim )
235
278
}
236
279
237
280
func NewAdaptiveAgent (sim * Simulation ) * AdaptiveAgent {
238
- return & AdaptiveAgent {
239
- lb : spellmap [MagicIDLB12 ],
240
- cl : spellmap [MagicIDCL6 ],
281
+ agent := & AdaptiveAgent {}
282
+
283
+ clearcastSimRequest := SimRequest {
284
+ Options : sim .Options ,
285
+ Gear : sim .EquipSpec ,
286
+ Iterations : 100 ,
241
287
}
288
+ clearcastSimRequest .Options .AgentType = AGENT_TYPE_CL_ON_CLEARCAST
289
+ clearcastResult := RunSimulation (clearcastSimRequest )
290
+
291
+ if clearcastResult .NumOom >= 5 {
292
+ agent .baseAgent = NewAgent (sim , AGENT_TYPE_FIXED_LB_ONLY )
293
+ agent .surplusAgent = NewAgent (sim , AGENT_TYPE_CL_ON_CLEARCAST )
294
+ } else {
295
+ agent .baseAgent = NewAgent (sim , AGENT_TYPE_CL_ON_CLEARCAST )
296
+ agent .surplusAgent = NewAgent (sim , AGENT_TYPE_FIXED_CL_ON_CD )
297
+ }
298
+
299
+ return agent
242
300
}
243
301
244
302
type AgentType int
@@ -254,6 +312,7 @@ const (
254
312
AGENT_TYPE_FIXED_9LB_1CL
255
313
AGENT_TYPE_FIXED_10LB_1CL
256
314
AGENT_TYPE_FIXED_LB_ONLY
315
+ AGENT_TYPE_FIXED_CL_ON_CD
257
316
AGENT_TYPE_ADAPTIVE
258
317
AGENT_TYPE_CL_ON_CLEARCAST
259
318
)
@@ -268,6 +327,7 @@ var ALL_AGENT_TYPES = []AgentType{
268
327
AGENT_TYPE_FIXED_9LB_1CL ,
269
328
AGENT_TYPE_FIXED_10LB_1CL ,
270
329
AGENT_TYPE_FIXED_LB_ONLY ,
330
+ AGENT_TYPE_FIXED_CL_ON_CD ,
271
331
AGENT_TYPE_ADAPTIVE ,
272
332
AGENT_TYPE_CL_ON_CLEARCAST ,
273
333
}
@@ -291,7 +351,9 @@ func NewAgent(sim *Simulation, agentType AgentType) Agent {
291
351
case AGENT_TYPE_FIXED_10LB_1CL :
292
352
return NewFixedRotationAgent (sim , 10 )
293
353
case AGENT_TYPE_FIXED_LB_ONLY :
294
- return NewFixedRotationAgent (sim , - 1 )
354
+ return NewLBOnlyAgent (sim )
355
+ case AGENT_TYPE_FIXED_CL_ON_CD :
356
+ return NewCLOnCDAgent (sim )
295
357
case AGENT_TYPE_ADAPTIVE :
296
358
return NewAdaptiveAgent (sim )
297
359
case AGENT_TYPE_CL_ON_CLEARCAST :
0 commit comments