Skip to content
Snippets Groups Projects
Commit a1ac21da authored by pjs's avatar pjs
Browse files

make demo reproducible with srand

parent 0ea7b8cf
No related branches found
No related tags found
No related merge requests found
...@@ -8,15 +8,16 @@ class MyModel ...@@ -8,15 +8,16 @@ class MyModel
def init def init
@x = 1 @x = 1
schedule(:increment, rand, 1, 97) schedule(:increment, rand(2), 1, 97)
end end
def increment(n, c) def increment(n, c)
@x += n @x += n
schedule(:increment, 2.0 * rand, @x, c + 1) schedule(:increment, 2.0 * rand(2), @x, c + 1)
printf "%f, %f, %c\n", model_time, @x, c printf "%f, %f, %c\n", model_time, @x, c
schedule(:halt, 0.0) if model_time > 10 schedule(:halt, 0.0) if model_time > 10
end end
end end
srand(42)
MyModel.new.run MyModel.new.run
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment