Module: Saize

Extended by:
Egison
Defined in:
lib/saize.rb,
lib/saize/version.rb

Defined Under Namespace

Classes: Menu, NetworkNode

Constant Summary collapse

Sample =

松屋に実際にあるメニュー。牛めしのようにプレミアムとそうでないものがある場合は、プレミアムだけを書くオリジナルカレギュウ(プレミアム牛肉使用)も、プレミアムとして扱い、プレミアム牛肉使用と書いていないほうは書かない

Set.new([ Menu.new(i[
Morning =

松屋の朝定食

Set.new()
VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.generate(okano: 0.1, current: network.find{|n|n.node == :begin}) ⇒ Object

お客様に提供する商品を作る。私は接客は不得意なので、ランダムなものが出てくる。おかの値が1に近づくほど狂った商品が出てくる。

Args

okano:

Float おかの値。おかの値が高いと商品が変異する確率が上がる。0-1の範囲の値。

current:

Matsuya::NetworkNode 再帰呼出し用。省略する。

Return

Array 材料を並べた配列



170
171
172
173
174
175
176
177
178
179
# File 'lib/saize.rb', line 170

def generate(okano: 0.1, current: network.find{|n|n.node == :begin})
  if current.is_a? NetworkNode
    nex = current.follow.sample
    if nex.is_a?(NetworkNode) and rand < okano
      [current.node, *generate(okano: okano, current: network.sample)]
    else
      [current.node, *generate(okano: okano, current: nex)]
    end
  end
end

.networkObject

松屋ネットワークを構築し、始点を返す。

Return

Matsuya::NetworkNode beginノード



146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/saize.rb', line 146

def network
  dic = {begin: NetworkNode.new(:begin, [])}
  Sample.each do |menu|
    [:begin, *menu.pattern, menu.price].each_cons(2) do |current, follow|
      node = dic[current] ||= NetworkNode.new(current, [])
      if follow.is_a? Symbol
        node.follow << dic[follow] ||= NetworkNode.new(follow, [])
      else
        node.follow << follow
      end
    end
  end
  dic.values
end

.order(okano = 0.1) ⇒ Object

商品を注文し、商品を受け取る

Args

okano

Float おかの値。おかの値が高いと商品が変異する確率が上がる。0-1の範囲の値。

Return

String 商品名



244
245
246
# File 'lib/saize.rb', line 244

def order(okano=0.1) # !> shadowing outer local variable - ys2
  preparation(generate.reject{|x|x==:begin}).join
end

.preparation(dish) ⇒ Object

材料を選択したら釜に入れてぐーるぐーる。キムカル丼のように、『キムチ+カルビ』がキムカルに変化するなど、松屋活用を考慮してMatsuya.generate の戻り値をStringに変換する

Args

dish

Array 現在の皿の状態

Return

String できたー!どの特性を残そう?



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/saize.rb', line 188

def preparation(dish)
  match(dish) do
    with(Egison::List.(*_head, :+, *_tail)) do
      if tail.last == :