mgmg 1.5.5 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcdae95e0d1ee5dc8d65fe012d739a896b5be27e2a68ff5a2619477461e2e9d7
4
- data.tar.gz: 2a2976e6c36a2cd2c3c6bc7c6e829f7e78e2791d18bc087188b369db7ecacb17
3
+ metadata.gz: 8ae7f8d4f1a701c2f96a4fddbcabdda81fad3355276a368cf7b987ee47e6bfa3
4
+ data.tar.gz: 26ee4b16fa9e8a97db0245ddc1019f94b8bbb166dac3fb1812a573cfc9920538
5
5
  SHA512:
6
- metadata.gz: d40a50cc4cde3a115d7d9f27a93945a27f4b77ece5091917d30cf32675679f6ae52290163168cd5d8c3cf57ded10f29bbb3a6fc803e67d209c35cf8c949f3912
7
- data.tar.gz: 27f15eef233a9f19a92bca31d4b4683e78fb1207768fd7b8cbc7cc2aab8d6d79c23ac3db93237a0e8b508dfaa4f50da745f001de50ce74bf5d34824ee3909dc6
6
+ metadata.gz: e973d0aed431aa65d45b479a3017a78c04e1d7403d8cebacc3337065c4111b382294e51d472a240a80bfea1ed9281860aaf3597225fb5da0088d50758632842c
7
+ data.tar.gz: d0ea591eaa7fe9418191289468592d1b207a434fc367a0e0a8811550a7104a7b2dfc9b75df60a929c83ceeda0c4e41915451718a3a25662dd93abe8b7b500986
data/CHANGELOG.md CHANGED
@@ -156,3 +156,8 @@
156
156
  ## 1.5.5 2022/07/02
157
157
  - `Enumerable#to_recipe`が動かなくなったバグを修正.
158
158
  - `String#min_level`において,正しい答えを返さなくなったバグを修正.
159
+
160
+ ## 1.5.6 2022/07/17
161
+ - `String#find_lowerbound`,`String#find_upperbound`における探索刻み幅を1から1/8に変更し,コーナーケースでの精度を上昇させた.
162
+ - `Enumerable#min_level`が,原料☆によるレベル制限を無視した値を返すことがあったバグを修正.
163
+ - `String#find_lowerbound`や`Mgmg::IR#atk_sd` などにおいて,返り値が,分母が1の`Rational`である場合,代わりに`Integer`を返すように修正.
data/lib/mgmg/equip.rb CHANGED
@@ -94,13 +94,13 @@ module Mgmg
94
94
  attack()+str()
95
95
  end
96
96
  def atk_sd
97
- attack()+str().quo(2)+dex().quo(2)
97
+ ( attack()+str().quo(2)+dex().quo(2) ).to_ii
98
98
  end
99
99
  def dex_as
100
- attack().quo(2)+str().quo(2)+dex()
100
+ ( attack().quo(2)+str().quo(2)+dex() ).to_ii
101
101
  end
102
102
  def mag_das
103
- magic()+dex_as().quo(2)
103
+ ( magic()+dex_as().quo(2) ).to_ii
104
104
  end
105
105
  def magic2
106
106
  magic()*2
@@ -122,18 +122,18 @@ module Mgmg
122
122
  when 6, 7
123
123
  [magic()*2, atkstr()].max
124
124
  when 28
125
- @para.sum-((hp()+mp())*3.quo(4))
125
+ ( @para.sum-((hp()+mp())*3.quo(4)) ).to_ii
126
126
  else
127
127
  ret = @para.max
128
128
  if ret == magdef()
129
- ret+magic().quo(2)
129
+ ( ret+magic().quo(2) ).to_ii
130
130
  else
131
131
  ret
132
132
  end
133
133
  end
134
134
  end
135
135
  def magmag
136
- magdef()+magic().quo(2)
136
+ ( magdef()+magic().quo(2) ).to_ii
137
137
  end
138
138
  def fpower
139
139
  power().to_f
data/lib/mgmg/ir.rb CHANGED
@@ -196,26 +196,26 @@ module Mgmg
196
196
  ret *= (100+r.vec[i]).quo(100)
197
197
  end
198
198
  end
199
- ret
199
+ ret.to_ii
200
200
  end
201
201
  end
202
202
  def atkstr(s, ac, x=nil)
203
203
  attack(s, ac, x)+str(s, ac, x)
204
204
  end
205
205
  def atk_sd(s, ac, x=nil)
206
- attack(s, ac, x)+str(s, ac, x).quo(2)+dex(s, ac, x).quo(2)
206
+ ( attack(s, ac, x)+str(s, ac, x).quo(2)+dex(s, ac, x).quo(2) ).to_ii
207
207
  end
208
208
  def dex_as(s, ac, x=nil)
209
- attack(s, ac, x).quo(2)+str(s, ac, x).quo(2)+dex(s, ac, x)
209
+ ( attack(s, ac, x).quo(2)+str(s, ac, x).quo(2)+dex(s, ac, x) ).to_ii
210
210
  end
211
211
  def mag_das(s, ac, x=nil)
212
- magic(s, ac, x)+dex_as(s, ac, x).quo(2)
212
+ ( magic(s, ac, x)+dex_as(s, ac, x).quo(2) ).to_ii
213
213
  end
214
214
  def magic2(s, ac, x=nil)
215
215
  magic(s, ac, x)*2
216
216
  end
217
217
  def magmag(s, ac, x=nil)
218
- magdef(s, ac, x)+magic(s, ac, x).quo(2)
218
+ ( magdef(s, ac, x)+magic(s, ac, x).quo(2) ).to_ii
219
219
  end
220
220
  def pmdef(s, ac, x=nil)
221
221
  [phydef(s, ac, x), magmag(s, ac, x)].min
@@ -234,7 +234,7 @@ module Mgmg
234
234
  when 6, 7
235
235
  [magic(s, c)*2, atkstr(s, c)].max
236
236
  when 28
237
- @para.enum_for(:sum).with_index do |e, i|
237
+ ( @para.enum_for(:sum).with_index do |e, i|
238
238
  x = e.evaluate3(s, a, c)
239
239
  @rein.each do |r|
240
240
  if r.vec[i] != 0
@@ -242,7 +242,7 @@ module Mgmg
242
242
  end
243
243
  end
244
244
  x
245
- end-((hp(s, a, c)+mp(s, a, c))*3.quo(4))
245
+ end - ((hp(s, a, c)+mp(s, a, c))*3.quo(4)) ).to_ii
246
246
  else
247
247
  ret = @para.map.with_index do |e, i|
248
248
  x = e.evaluate3(s, a, c)
@@ -252,9 +252,9 @@ module Mgmg
252
252
  end
253
253
  end
254
254
  x
255
- end.max
255
+ end.max.to_ii
256
256
  if ret == magdef(s, a, c)
257
- ret+magic(s, a, c).quo(2)
257
+ ( ret+magic(s, a, c).quo(2) ).to_ii
258
258
  else
259
259
  ret
260
260
  end
data/lib/mgmg/poly.rb CHANGED
@@ -109,7 +109,7 @@ module Mgmg
109
109
  if a == c
110
110
  return( b == d )
111
111
  else
112
- return( (d-b).quo(a-c) )
112
+ return( (d-b).quo(a-c).to_ii )
113
113
  end
114
114
  end
115
115
  def smith_fix(smith, fmt=nil)
data/lib/mgmg/search.rb CHANGED
@@ -224,6 +224,8 @@ module Enumerable
224
224
  end
225
225
 
226
226
  module Mgmg
227
+ Eighth = 1.quo(8)
228
+ using Refiner
227
229
  module_function def find_lowerbound(a, b, para, start, term, opt_a: Option.new, opt_b: Option.new)
228
230
  if term <= start
229
231
  raise ArgumentError, "start < term is needed, (start, term) = (#{start}, #{term}) are given"
@@ -245,7 +247,7 @@ module Mgmg
245
247
  if eb < ea || ( ea == eb && opt_a.irep.para_call(para, *sca) < opt_b.irep.para_call(para, *scb) )
246
248
  a, b, opt_a, opt_b, sca, scb, ea, eb = b, a, opt_b, opt_a, scb, sca, eb, ea
247
249
  end
248
- tag = opt_a.irep.para_call(para, *sca) + 1
250
+ tag = opt_a.irep.para_call(para, *sca) + Eighth
249
251
  sca, scb = a.search(para, term, opt: opt_a), b.search(para, term, opt: opt_b)
250
252
  ea, eb = Mgmg.exp(*sca), Mgmg.exp(*scb)
251
253
  if ea < eb || ( ea == eb && opt_b.irep.para_call(para, *scb) < opt_a.irep.para_call(para, *sca) )
@@ -256,15 +258,15 @@ module Mgmg
256
258
  ea, eb = Mgmg.exp(*sca), Mgmg.exp(*scb)
257
259
  pa, pb = opt_a.irep.para_call(para, *sca), opt_b.irep.para_call(para, *scb)
258
260
  if eb < ea
259
- return [tag-1, pb]
261
+ return [(tag-Eighth).to_ii, pb]
260
262
  elsif ea == eb
261
263
  if pa < pb
262
- return [tag-1, pa]
264
+ return [(tag-Eighth).to_ii, pa]
263
265
  else
264
- tag = pb + 1
266
+ tag = pb + Eighth
265
267
  end
266
268
  else
267
- tag = pa + 1
269
+ tag = pa + Eighth
268
270
  end
269
271
  end
270
272
  raise UnexpectedError
@@ -309,22 +311,22 @@ module Mgmg
309
311
  pa, pb = opt_a.irep.para_call(para, *sca), opt_b.irep.para_call(para, *scb)
310
312
  if ea < eb
311
313
  ret = tagl
312
- sca = a.search(para, pa + 1, opt: opt_a)
314
+ sca = a.search(para, pa + Eighth, opt: opt_a)
313
315
  tagl = opt_a.irep.para_call(para, *sca)
314
316
  scb = b.search(para, tagl, opt: opt_b)
315
317
  elsif ea == eb
316
318
  if pb < pa
317
319
  ret = tagl
318
- sca = a.search(para, pa + 1, opt: opt_a)
320
+ sca = a.search(para, pa + Eighth, opt: opt_a)
319
321
  tagl = opt_a.irep.para_call(para, *sca)
320
322
  scb = b.search(para, tagl, opt: opt_b)
321
323
  else
322
- scb = b.search(para, pb + 1, opt: opt_b)
324
+ scb = b.search(para, pb + Eighth, opt: opt_b)
323
325
  tagl = opt_b.irep.para_call(para, *scb)
324
326
  sca = a.search(para, tagl, opt: opt_a)
325
327
  end
326
328
  else
327
- sca = a.search(para, pa + 1, opt: opt_a)
329
+ sca = a.search(para, pa + Eighth, opt: opt_a)
328
330
  tagl = opt_a.irep.para_call(para, *sca)
329
331
  scb = b.search(para, tagl, opt: opt_b)
330
332
  end
@@ -337,11 +339,17 @@ module Mgmg
337
339
  tagl = term
338
340
  end
339
341
  else
340
- pa = opt_a.irep.para_call(para, *a.search(para, ret+1, opt: opt_a))
341
- pb = opt_b.irep.para_call(para, *b.search(para, ret+1, opt: opt_b))
342
- return [ret, [pa, pb].min]
342
+ pa = opt_a.irep.para_call(para, *a.search(para, ret+Eighth, opt: opt_a))
343
+ pb = opt_b.irep.para_call(para, *b.search(para, ret+Eighth, opt: opt_b))
344
+ return [ret.to_ii, [pa, pb].min]
343
345
  end
344
346
  end
345
347
  raise UnexpectedError
346
348
  end
349
+
350
+ module_function def find_lubounds(a, b, para, lower, upper, opt_a: Mgmg::Option.new, opt_b: Mgmg::Option.new)
351
+ xl, yl = find_lowerbound(a, b, para, lower, upper, opt_a:, opt_b:)
352
+ xu, yu = find_upperbound(a, b, para, upper, lower, opt_a:, opt_b:)
353
+ [xl, yl, xu, yu]
354
+ end
347
355
  end
data/lib/mgmg/utils.rb CHANGED
@@ -13,6 +13,8 @@ module Mgmg
13
13
  self.div(other)
14
14
  end
15
15
  end
16
+
17
+ alias :to_ii :itself
16
18
  end
17
19
  refine Float do
18
20
  alias :cdiv :quo # Floatの場合は普通の割り算
@@ -55,6 +57,14 @@ module Mgmg
55
57
  self.to_f.comma3
56
58
  end
57
59
  end
60
+
61
+ def to_ii
62
+ if self.denominator == 1
63
+ self.numerator
64
+ else
65
+ self
66
+ end
67
+ end
58
68
  end
59
69
  end
60
70
  using Refiner
data/lib/mgmg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mgmg
2
- VERSION = "1.5.5"
2
+ VERSION = "1.5.6"
3
3
  end
data/lib/mgmg.rb CHANGED
@@ -226,7 +226,7 @@ module Enumerable
226
226
  built = recipe.build(opt:)
227
227
  w = recipe.build(built.min_levels_max[i], opt:).weight - w if w <= 0
228
228
  return -1 if include_outsourcing && built.weight <= w
229
- return ms if build(ms, opt:).weight <= w
229
+ return ms if recipe.build(ms, opt:).weight <= w
230
230
  ary = [ms]
231
231
  4.downto(1) do |wi|
232
232
  built.min_levels(wi).values.each do |v|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mgmg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - KAZOON
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-01 00:00:00.000000000 Z
11
+ date: 2022-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.3.17
107
+ rubygems_version: 3.3.18
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Calculate specs of equipments of Megurimeguru, a game produced by Kou.