Class: GameSimulator

Inherits:
Object
  • Object
show all
Defined in:
lib/were_wolf/game_simulator.rb

Instance Method Summary collapse

Constructor Details

#initialize(no_of_wolves, no_of_villagers, no_of_runs) ⇒ GameSimulator

Returns a new instance of GameSimulator.



4
5
6
7
8
# File 'lib/were_wolf/game_simulator.rb', line 4

def initialize(no_of_wolves, no_of_villagers, no_of_runs)
  @no_of_wolves = no_of_wolves
  @no_of_villagers = no_of_villagers
  @no_of_runs = no_of_runs
end

Instance Method Details

#simulateObject



10
11
12
13
14
15
16
17
# File 'lib/were_wolf/game_simulator.rb', line 10

def simulate
  wins = Hash.new(0)
  @no_of_runs.times do
    wins[Game.new(@no_of_wolves, @no_of_villagers).run] += 1
  end

  return wins
end