mgmg 1.8.1 → 1.8.3

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: 3698312de546d3f9a7eac1aadd6024ae8132a8c58f97c041fa07b788828a3bcc
4
- data.tar.gz: 19d8263ccfd11a476472868a8420959cccc356bbd7f69fcf619f831fde589794
3
+ metadata.gz: 820d3de4f30f6181ec34796140bcc701ced11426541270a921b9b9695eadcba4
4
+ data.tar.gz: c627160e3ed9f4c43b586a086aa337b447731e8127d32a5a7d2fd90540af4394
5
5
  SHA512:
6
- metadata.gz: c0edb6042eb1fccbe9d6b4761afd1a2ad0814910850b2664325d20f109fe9d6805cf28aab5d25b363842cde62dce3e1739319668446e912b6a15d94e2043654f
7
- data.tar.gz: 70ed1f01ca7bfd7ef4be9fc886f74f2049d466cc73e2fb79276dd9768d40bed0232119cde2a177def7721f677271ff602b71d3231d207a94a5850fcd82844b8a
6
+ metadata.gz: 8db38968933286866d9d35b1aa42de2dc60b67bb34e3b687badae85d743911e95bbcdb43dd29a4011c66c207c2d9f1799e5e5e2796c94bbc6d552875d0be05c0
7
+ data.tar.gz: d7837e35f2b596a25d4464ad1a64a2de9ec8b4e45ffa5cd72aea73943eff0937ea2d51dd4378b89a32016ed67a43c3a414a60e1025fadae73856c00a659e83b2
data/CHANGELOG.md CHANGED
@@ -194,3 +194,9 @@
194
194
  - `Mgmg::Recipe`に`name`属性を追加.`String/Enumerable#to_recipe`の際,キーワード引数`name`を追加することで設定できる.
195
195
  - `Mgmg.#efficient_list` を追加.
196
196
  - `Enumerable#build`,`Enumerable#search`で意図せぬ例外が発生していた問題を修正.
197
+
198
+ ## 1.8.2 2022/11/21
199
+ - オプション`cut_exp`で探索が打ち切られる場合に,`Mgmg::SearchCutException`でない例外が発生する場合があったバグを修正.
200
+
201
+ ## 1.8.3 2025/08/19
202
+ - リファレンスのタイポを修正.
data/lib/mgmg/recipe.rb CHANGED
@@ -86,16 +86,24 @@ module Mgmg
86
86
  raise BrokenRecipeError
87
87
  end
88
88
  end
89
- def show(smith=-1, armor=smith, comp=armor.tap{armor=smith}, para: @para, **kw)
89
+ def show(smith=-1, armor=smith, comp=armor.tap{armor=smith}, para: @para, search: nil, find_max: nil, **kw)
90
90
  opt = temp_opt(**kw)
91
- smith, armor, comp = opt.smith_min, opt.armor_min, opt.comp_min if smith.nil?
92
- case @recipe
93
- when String
94
- @recipe.show(smith, comp, para:, name: @name, opt:)
95
- when Enumerable
96
- @recipe.show(smith, armor, comp, para:, name: @name, opt:)
91
+ if search
92
+ sc = @recipe.search(para, search, opt:)
93
+ @recipe.show(*sc, para:, name: @name, opt:)
94
+ elsif find_max
95
+ sc = @recipe.search(para, find_max, opt:)
96
+ @recipe.show(*sc, para:, name: @name, opt:)
97
97
  else
98
- raise BrokenRecipeError
98
+ smith, armor, comp = opt.smith_min, opt.armor_min, opt.comp_min if smith.nil?
99
+ case @recipe
100
+ when String
101
+ @recipe.show(smith, comp, para:, name: @name, opt:)
102
+ when Enumerable
103
+ @recipe.show(smith, armor, comp, para:, name: @name, opt:)
104
+ else
105
+ raise BrokenRecipeError
106
+ end
99
107
  end
100
108
  end
101
109
  def search(target, para: @para, **kw)
data/lib/mgmg/search.rb CHANGED
@@ -69,6 +69,7 @@ class String
69
69
  [exp_best, ret]
70
70
  end
71
71
  def search(para, target, opt: Mgmg::Option.new)
72
+ org_cut_exp = opt.cut_exp
72
73
  opt = opt.dup.set_default(self)
73
74
  opt_nocut = opt.dup; opt_nocut.cut_exp = Float::INFINITY
74
75
  begin
@@ -109,6 +110,7 @@ class String
109
110
  end
110
111
  end
111
112
  exp_best = opt.cut_exp
113
+ values = values.filter(&:finite?)
112
114
  diff = values.max-values.min
113
115
  if 0 < diff
114
116
  opt.cut_exp = exp_best + diff*opt.fib_ext[0]
@@ -124,8 +126,8 @@ class String
124
126
  end
125
127
  end
126
128
  if ret.nil?
127
- max = opt.irep.para_call(para, *find_max(para, opt.cut_exp, opt:))
128
- raise Mgmg::SearchCutException, "the maximum output with given cut_exp=#{opt.cut_exp.comma3} is #{max.comma3}, which does not reach given target=#{target.comma3}"
129
+ max = opt.irep.para_call(para, *find_max(para, org_cut_exp, opt:))
130
+ raise Mgmg::SearchCutException, "the maximum output with given cut_exp=#{org_cut_exp.comma3} is #{max.comma3}, which does not reach given target=#{target.comma3}"
129
131
  end
130
132
  ret
131
133
  end
@@ -178,6 +180,7 @@ class String
178
180
  values = [values[1], values[2], cur, values[3]]
179
181
  end
180
182
  end
183
+ values = values.filter(&:finite?)
181
184
  diff = values.max-values.min
182
185
  if 0 < diff
183
186
  th = max - diff*opt.fib_ext[1]
@@ -338,6 +341,7 @@ module Enumerable
338
341
  [exp_best, ret]
339
342
  end
340
343
  def search(para, target, opt: Mgmg::Option.new)
344
+ org_cut_exp = opt.cut_exp
341
345
  opt = opt.dup.set_default(self)
342
346
  begin
343
347
  opt.comp_min = comp_search(para, target, opt.smith_max, opt.armor_max, opt:)
@@ -377,6 +381,7 @@ module Enumerable
377
381
  end
378
382
  end
379
383
  exp_best = opt.cut_exp
384
+ values = values.filter(&:finite?)
380
385
  diff = values.max-values.min
381
386
  if 0 < diff
382
387
  opt.cut_exp = exp_best + diff*opt.fib_ext[0]
@@ -392,8 +397,8 @@ module Enumerable
392
397
  end
393
398
  end
394
399
  if ret.nil?
395
- max = opt.irep.para_call(para, *find_max(para, opt.cut_exp, opt:))
396
- raise Mgmg::SearchCutException, "the maximum output with given cut_exp=#{opt.cut_exp.comma3} is #{max.comma3}, which does not reach given target=#{target.comma3}"
400
+ max = opt.irep.para_call(para, *find_max(para, org_cut_exp, opt:))
401
+ raise Mgmg::SearchCutException, "the maximum output with given cut_exp=#{org_cut_exp.comma3} is #{max.comma3}, which does not reach given target=#{target.comma3}"
397
402
  end
398
403
  ret
399
404
  end
@@ -444,6 +449,7 @@ module Enumerable
444
449
  cur = cur_i if cur < cur_i
445
450
  end
446
451
  end
452
+ a_vals = a_vals.filter(&:finite?)
447
453
  diff = a_vals.max-a_vals.min
448
454
  if 0 < diff
449
455
  th = max - diff*opt.fib_ext[1]
@@ -486,6 +492,7 @@ module Enumerable
486
492
  values = [values[1], values[2], cur, values[3]]
487
493
  end
488
494
  end
495
+ values = values.filter(&:finite?)
489
496
  diff = values.max-values.min
490
497
  if 0 < diff
491
498
  th = max - diff*opt.fib_ext[1]
data/lib/mgmg/utils.rb CHANGED
@@ -166,6 +166,7 @@ module Mgmg
166
166
  end
167
167
  end
168
168
  module_function def invexp2(exp, comp)
169
+ raise ArgumentError, "exp must be finite" unless exp.finite?
169
170
  begin
170
171
  ret = Math.sqrt(exp - (2*((comp-1)**2)) - 3).floor + 2
171
172
  rescue Math::DomainError
@@ -178,6 +179,7 @@ module Mgmg
178
179
  end
179
180
  end
180
181
  module_function def invexp2c(exp, s)
182
+ raise ArgumentError, "exp must be finite" unless exp.finite?
181
183
  begin
182
184
  ret = Math.sqrt((exp - (((s-1)**2)) - 3).quo(2)).floor + 2
183
185
  rescue Math::DomainError
@@ -190,6 +192,7 @@ module Mgmg
190
192
  end
191
193
  end
192
194
  module_function def invexp3(exp, sa, comp)
195
+ raise ArgumentError, "exp must be finite" unless exp.finite?
193
196
  return invexp2(exp, comp) if sa < 0
194
197
  begin
195
198
  ret = Math.sqrt(exp - ((sa-1)**2) - (2*((comp-1)**2)) - 4).floor + 2
@@ -203,6 +206,7 @@ module Mgmg
203
206
  end
204
207
  end
205
208
  module_function def invexp3c(exp, smith, armor)
209
+ raise ArgumentError, "exp must be finite" unless exp.finite?
206
210
  if smith < 0
207
211
  return invexp2c(exp, armor)
208
212
  elsif armor < 0
data/lib/mgmg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mgmg
2
- VERSION = "1.8.1"
2
+ VERSION = "1.8.3"
3
3
  end
data/reference.md CHANGED
@@ -208,7 +208,7 @@ end
208
208
  ブロックを指定していない場合,常に`former`が優先されます.
209
209
 
210
210
  ## `String#eff(para, smith, comp=smith, opt: Mgmg.option())`
211
- [`smith`を1上げたときの`para`値/(`smith`を1上げるのに必要な経験値), `comp`を1上げたときの`para`値/(`comp`を2上げるのに必要な経験値)]を返します.
211
+ [`smith`を1上げたときの`para`値/(`smith`を1上げるのに必要な経験値), `comp`を2上げたときの`para`値/(`comp`を2上げるのに必要な経験値)]を返します.
212
212
  `para`は,`Mgmg::Equip`のメソッド名をシンボルで指定(`:power, :fpower`も可)します.
213
213
 
214
214
  `opt`は`String#build`にそのまま渡されます.
@@ -261,11 +261,11 @@ end
261
261
  製作に必要な総エレメント量を,火,地,水の順のベクトルとして返します.ケージの十分性の確認には,下記の`comp_cost`を用います.
262
262
 
263
263
  ## `Mgmg::Equip#comp_cost(outsourcing=false)`
264
- `self`が合成によって作られたものだとした場合の消費地エレメント量を返します.地ケージ確保のための確認用途が多いと思うので短い`cost`をエイリアスとしています.`outsourcing`が真の場合,街の道具製作屋に頼んだ場合のコストを返します.
264
+ `self`が合成によって作られたものだと仮定した場合の消費地エレメント量を返します.地ケージ確保のための確認用途が多いと思うので短い`cost`をエイリアスとしています.`outsourcing`が真の場合,街の道具製作屋に頼んだ場合のコストを返します.
265
265
  武器なら火エレメント,防具なら水エレメントを,地エレメントと同値分だけ消費するため,火または水ケージも同量必要となります.
266
266
 
267
267
  ## `Mgmg::Equip#smith_cost(outsourcing=false)`
268
- `self`が鍛冶・防具製作によって作られたものだったものだとした場合の消費火・水エレメント量を返します.`outscourcing`が真の場合,街の鍛冶屋・防具製作屋に頼んだ場合のコストを返します.
268
+ `self`が鍛冶・防具製作によって作られたものだったものだと仮定した場合の消費火・水エレメント量を返します.`outscourcing`が真の場合,街の鍛冶屋・防具製作屋に頼んだ場合のコストを返します.
269
269
 
270
270
  ## `Mgmg::Equip#attack, phydef, magdef, hp, mp, str, dex, speed, magic, fire, earth, water`
271
271
  それぞれ
@@ -305,7 +305,7 @@ end
305
305
  の威力です.トリックプレーやディバイドには対応していません.
306
306
 
307
307
  ## `Mgmg::Equip#magmag`
308
- 「魔防+魔力/2」の値を返します.魔力の半分が魔防に加算されることから,実際の魔防性能となります.
308
+ 「魔防+魔力/2」の値を返します.魔力の半分が魔防に加算されることから,実際の魔防性能となります.この値を実効魔防とよびます.
309
309
 
310
310
  ## `Mgmg::Equip#pmdef`
311
311
  物防と実効魔防のうち,小さい方を返します.
@@ -366,7 +366,7 @@ end
366
366
  最高次係数を返します.`fmt`が`nil`なら数値(`Rational`)をそのまま,それ以外なら`Mgmg::TPolynomial#to_s`と同様の方式で文字列に変換して返します.ただし,レシピの段数に応じた最高次数を返すため,レシピ次第では本メソッドの返り値が`0`となり,それより低い次数の項が最高次となることもあり得ます.そのようなケースでの真の最高次の探索はしません.
367
367
 
368
368
  ## `Mgmg::TPolynomial#[](i, j)`
369
- 鍛冶・防具製作Lvをs,道具製作Lvをcとして,s<sup>i</sup>c<sup>j</sup> の係数を返します.負の値を指定すると,最高次から降順に数えた次数の項の係数を返します.例えば`i, j = -1, -1`なら,最高次の係数となります.引数が正で範囲外なら`0`を返し,負で範囲外なら`IndexError`を上げます.
369
+ 鍛冶・防具製作Lvをs,道具製作Lvをcとして,s<sup>i</sup>c<sup>j</sup> の係数を返します.負の値を指定すると,最高次から降順に数えた次数の項の係数を返します.例えば`i, j = -1, -1`なら,最高次の係数となります.引数が正で範囲外なら`0`を返し,負で範囲外なら`IndexError`を発生します.
370
370
 
371
371
  ## `Mgmg::TPolynomial#evaluate(smith, comp=smith)`
372
372
  鍛冶・防具製作Lvを`smith`,道具製作Lvを`comp`として値を計算します.丸めを無視しているため,実際の合成結果以上の値が返ります.
@@ -398,7 +398,7 @@ alias として`*`があるほか`scalar(1.quo(value))`として`quo`,`/`,`s
398
398
  ```ruby
399
399
  "斧☆14(皮鉄)<攻撃:[110(s+170)/100]+[[[86(s+135)/100][(c+130)/2]/100]/100], 腕力:[14(s+170)/100]>"
400
400
  ```
401
- のような文字列を返します.ここで,sは鍛冶Lv,sは道具製作Lvを表します.防具の場合,sの代わりに防具製作Lvを表すaが用いられます.「[]」は,0への丸めを意味し,掛け算記号は省略されています.
401
+ のような文字列を返します.ここで,sは鍛冶Lv,cは道具製作Lvを表します.防具の場合,sの代わりに防具製作Lvを表すaが用いられます.「[]」は,0への丸めを意味し,掛け算記号は省略されています.
402
402
 
403
403
  ## `Mgmg::IR#attack, phydef, magdef, hp, mp, str, dex, speed, magic(s=nil, ac=s, x=nil)`
404
404
  それぞれ
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mgmg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - KAZOON
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-11-19 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -52,7 +51,6 @@ dependencies:
52
51
  - - ">="
53
52
  - !ruby/object:Gem::Version
54
53
  version: 1.4.1
55
- description:
56
54
  email:
57
55
  - cycloawaodorin+gem@gmail.com
58
56
  executables: []
@@ -89,7 +87,6 @@ metadata:
89
87
  homepage_uri: https://github.com/cycloawaodorin/
90
88
  source_code_uri: https://github.com/cycloawaodorin/mgmg
91
89
  changelog_uri: https://github.com/cycloawaodorin/mgmg/blob/master/CHANGELOG.md
92
- post_install_message:
93
90
  rdoc_options: []
94
91
  require_paths:
95
92
  - lib
@@ -104,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
101
  - !ruby/object:Gem::Version
105
102
  version: '0'
106
103
  requirements: []
107
- rubygems_version: 3.3.26
108
- signing_key:
104
+ rubygems_version: 3.7.1
109
105
  specification_version: 4
110
106
  summary: Calculate specs of equipments of Megurimeguru, a game produced by Kou.
111
107
  test_files: []