Search code examples
netlogorandom-seed

How do I use the random-seed command in Netlogo to ensure runs of my model have the reproducible results?


I am currently working on a model that uses randomness in a few places. Since I want the runs of this model to have results that are reproducible, I would like the drawn numbers to be the same with each re-run of the model.

I have tried using the random-seed command, since I read that this is how to do this in Netlogo. I first just put in a number, so: random-seed 1520. After that did not work I tried the new-seedreporter. I first tried: let my-seed new-seed set random-seed my-seed, since that is how it was in the code example. I am using Netlogo 6.3.0, by the way. I expected the inclusion of the random seed to ensure that the model would come to the same results each time I pressed setup and go, instead of fluctuating like it did before.


Solution

  • random-seed <number> works fine. I think the issue you are facing here is located somewhere else, but without more information, I can't help. Are you sure that you set the random-seed in your setup procedure correctly?

    Besides the dictonary you also find help in the programming guide. Furthermore there is a random-seed example model in the models library.

    This code works fine:

    to setup
      clear-all
      random-seed 1
      repeat 5 [print random 100]
    end