Class: Dogfood::DayGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/dogfood/day_generator.rb

Constant Summary collapse

DEFAULTS =
{ days: 1, wo_per_day: (3..6), fleet_ratio: 0.25, seed: nil }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(pack:, days: nil, wo_per_day: nil, fleet_ratio: nil, seed: nil, scenario: nil) ⇒ DayGenerator

Returns a new instance of DayGenerator.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dogfood/day_generator.rb', line 9

def initialize(pack:, days: nil, wo_per_day: nil, fleet_ratio: nil, seed: nil, scenario: nil)
  @pack = pack
  @config = DEFAULTS.dup
  @config[:days] = days if days
  @config[:wo_per_day] = wo_per_day if wo_per_day
  @config[:fleet_ratio] = fleet_ratio if fleet_ratio
  @config[:seed] = seed if seed
  @scenario = scenario&.to_sym
  @rng = Dogfood::Randomness.new(seed: @config[:seed])
  @ledger = Dogfood::Ledger.new
  @builder = Dogfood::StoryBuilder.new(pack: @pack, rng: @rng)
end

Instance Method Details

#generateObject



22
23
24
25
# File 'lib/dogfood/day_generator.rb', line 22

def generate
  days = @config[:days].times.map { |i| build_day(i) }
  { days: days, seed: @rng.seed }
end