Class: Rubygoal::Simulator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rubygoal/simulator.rb

Instance Method Summary collapse

Constructor Details

#initializeSimulator

Returns a new instance of Simulator.



10
11
12
13
# File 'lib/rubygoal/simulator.rb', line 10

def initialize
  Rubygoal.configuration.record_game = true
  @game = Rubygoal::Game.new(load_coach(:home), load_coach(:away))
end

Instance Method Details

#simulateObject



15
16
17
18
19
20
21
22
23
# File 'lib/rubygoal/simulator.rb', line 15

def simulate
  time = Time.now

  while !game.ended? do
    game.update
    time += 1.0 / 60.0
    Timecop.travel(time)
  end
end