-
Notifications
You must be signed in to change notification settings - Fork 0
/
priorityOptimization.py
85 lines (74 loc) · 2.23 KB
/
priorityOptimization.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
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 03 10:03:13 2016
@author: rmondoncancel
"""
import copy
from simulator import simulate
from priorityParser import priorityParser, priorityDeparser
# Run the optimization algorithm to find the best priority order to maximize
# the DPS
# Simulation parameters
model = 'monk'
duration = 5
variation = 0
nbSim = 1
runStatWeights = False
randomize = False
# Get priority list
(priorityList, character) = priorityParser(model)
# Get damage limit to run simulation with HP limit
dmgLimit = simulate(
(priorityList, character),
duration,
variation,
nbSim,
runStatWeights = runStatWeights,
randomize = randomize,
dmgLimit = 'get',
verbose = False
)
# Get reference DPS for damage limit
(_, _, refDPS, _, _, _, _) = simulate(
(priorityList, character),
duration,
variation,
nbSim,
runStatWeights = runStatWeights,
randomize = randomize,
dmgLimit = dmgLimit,
verbose = False
)
print 'Reference DPS: ', refDPS
unoptimized = True
while unoptimized :
unoptimized = False
# Try to switch two elements from the priority list and calcuate the new DPS
for i in range(len(priorityList) - 1):
# for j in range(i + 1, len(priorityList)):
j = i+1
newPriorityList = copy.deepcopy(priorityList)
newPriorityList[i], newPriorityList[j] = newPriorityList[j], newPriorityList[i]
(_, _, newDPS, _, _, _, _) = simulate(
(newPriorityList, character),
duration,
variation,
nbSim,
runStatWeights = runStatWeights,
randomize = randomize,
dmgLimit = dmgLimit,
verbose = False
)
print newDPS
# if new DPS is higher than old DPS update reference DPS
if newDPS > refDPS * 1.0001:
unoptimized = True
bestPerm = (i, j)
refDPS = newDPS
#
if unoptimized :
# if reference DPS has changed, update priority list accordingly
print 'Reference DPS: ', refDPS
priorityList[bestPerm[0]], priorityList[bestPerm[1]] = priorityList[bestPerm[1]], priorityList[bestPerm[0]]
# Print the priority list in correct order
print priorityDeparser(priorityList)