Blueprint for managing randomness

Blueprint for managing randomness preview image

1 collaborator

Default-person Matteo Sposato (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.2.0 • Viewed 86 times • Downloaded 10 times • Run 0 times
Download the 'Blueprint for managing randomness' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [
 current-seed
]

to setup
  clear-all
  reset-ticks

  manage-randomness
end 

to manage-randomness
; This procedure checks if the user wants to use a new seed given by the 'new-seed' primitive, or if
; they want to use a custom-defined seed. In the latter case, the custom-defined seed is retrieved
; from the 'custom-seed' global variable, which is set in the Interface in the input box. Such variable
; can be defined either manually by the user, or through the 'save-current-seed-as-custom' button (see
; the 'save-current-seed-as-custom' procedure below).
; In either case, this selection is mediated by the 'current-seed' global variable. This is because
; having a global variable storing the value that will be passed to the 'random-seed' primitive is the
; only way to [1] have such value displayed in the Interface, and [2] re-use such value in case the
; user wants to perform 'save-current-seed-as-custom'.

  ifelse (use-custom-seed?)
   [set current-seed custom-seed]
   [set current-seed new-seed]

  random-seed current-seed
end 

to save-current-seed-as-custom
; This procedure lets the user store the seed that was used in the current run (and stored in the
; 'random-seed' global variable; see comment in 'manage-randomness') as 'custom-seed', which will
; allow such value to be re-used after turning on the 'use-custom-seed?' switch in the Interface.

  set custom-seed current-seed
end 

to go
; The first if-statement allows the user to bring the run to a custom-defined ticks value.
; The custom-defined ticks value is retrieved from the 'custom-ticks' global variable,
; which is set in the Interface in the input box. Such variable can be defined either
; manually by the user, or through the 'save-current-ticks-as-custom' button (see the
; 'save-current-ticks-as-custom' procedure above).

  if (use-custom-ticks?) AND (ticks = custom-ticks) [stop]

  ; Insert here the normal 'go' procedure.

  tick
end 

to save-current-ticks-as-custom
; This procedure lets the user store the current 'ticks' value as 'custom-ticks'. This will allow
; the user, after switching on the 'use-custom-ticks?' switch, to bring the simulation to the
; exact same ticks as when the 'save-current-ticks-as-custom' button was used. If used in combination
; with the 'save-current-seed-as-custom' button and 'use-custom-seed?' switch, this allows the user
; to surely and quickly jump to the exact same situation as when a previous simulation was interrupted.

  set custom-ticks ticks
end 

There is only one version of this model, created over 2 years ago by Matteo Sposato.

Attached files

File Type Description Last updated
Blueprint for managing randomness.png preview Preview for 'Blueprint for managing randomness' over 2 years ago, by Matteo Sposato Download

This model does not have any ancestors.

This model does not have any descendants.