Skip to content
Snippets Groups Projects
MyModelArgs.rb 608 B
#!/usr/bin/env ruby

# expand the $LOAD_PATH to find local library modules until such
# time as this gets turned into a Ruby Gem.
[File.expand_path(File.dirname(__FILE__), '../lib')].each do |new_location|
  $LOAD_PATH.unshift(new_location) unless $LOAD_PATH.include?(new_location)
end
require 'simplekit'

class MyModel
  include SimpleKit

  def init
    @x = 1
    schedule(:increment, rand, 1, 97)
  end

  def increment(n, c)
    @x += n
    schedule(:increment, 2.0 * rand, @x, c + 1)
    printf "%f, %f, %c\n", model_time, @x, c
    schedule(:halt, 0.0) if model_time > 10
  end

end

MyModel.new.run