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
|
# File 'lib/mgmg/optimize.rb', line 5
def phydef_optimize(str, smith, comp=smith, opt: Option.new)
best = if smith.nil? then
[str, str.poly(:phydef, opt:), str.poly(:magdef, opt:), str.poly(:cost, opt:)]
else
[str, str.build(smith, comp, opt:)]
end
str = Mgmg.check_string(str)
ai = 0
while str.sub!(/(帽子|フード|サンダル)\([宝木骨][12][宝木骨]1\)/){
ai += 1
"<A#{ai}>"
}; end
bi = 0
while str.sub!(/[宝木骨]1\)/){
bi += 1
"<B#{bi}>)"
}; end
skin = false
m = /([^\+]*\([^\(]+[綿皮]1\))\]*\Z/.match(str)
if m
if smith
if m[1].sub(/綿1\)/, '皮1)').build(smith, opt:).weight == m[1].sub(/皮1\)/, '綿1)').build(smith, opt:).weight
skin = true
end
else
skin = true
end
str = str.sub(/皮(1\)\]*)\Z/) do
"綿#{$1}"
end
end
a = Array.new(ai){ [0, 0, 0] }
b0 = Array.new(bi){ 0 }
while a
b = b0
while b
r = pd_apply_idx(str, a, b)
best = if smith.nil? then
pd_better(best, [r, r.poly(:phydef, opt:), r.poly(:magdef, opt:), r.poly(:cost, opt:)], opt.magdef_maximize)
else
pd_better(best, [r, r.build(smith, comp, opt:)], opt.magdef_maximize)
end
b = pd_next_b(b)
end
a = pd_next_a(a)
end
if skin
str = str.sub(/綿(1\)\]*)\Z/) do
"皮#{$1}"
end
a = Array.new(ai){ [0, 0, 0] }
while a
b = b0
while b
r = pd_apply_idx(str, a, b)
best = if smith.nil? then
pd_better(best, [r, r.poly(:phydef, opt:), r.poly(:magdef, opt:), r.poly(:cost, opt:)], opt.magdef_maximize)
else
pd_better(best, [r, r.build(smith, comp, opt:)], opt.magdef_maximize)
end
b = pd_next_b(b)
end
a = pd_next_a(a)
end
end
best[0]
end
|