@@ -117,18 +117,15 @@ State variable `infected-neighbours` is a counter for the number of infected nei
Processes simulated by the model are [Dispersal](#dispersal), [Infection](#infection) and [Disease course](#disease-course). Processes are executed on every monthly time step in the above order.
After to model processes, the patch colour is updated for [Visualization](#visualization).
After to model processes, the patch colour is updated for [Visualization](#visualization) and the model tick is increased by one.
```netlogo
;- Go
to go
if ticks mod 12 = 0 [
assign-dispersal
]
disperse
disperse-offspring
infect-patches
age-infection
update-patches
tick
end
...
...
@@ -184,10 +181,26 @@ The model is composed of four submodels:
#### Dispersal
At the start of each year, the month of the next dispersal (`dispersal-tick`) is assigned to each fox family (i.e. to each non-empty patch), drawn from a uniform distribution covering the dispersal period.
The month of dispersal of each fox family is determined once per year. Actual dispersals are processed at every tick.
```netlogo
;- Dispersal
to disperse-offspring
if ticks mod 12 = 0 [
assign-dispersal
]
disperse
end
; ==> Assign dispersal.
; ==> Disperse.
```
At the start of each year, the month of the next dispersal (`dispersal-tick`) is assigned to each fox family (i.e. to each non-empty patch), drawn from a uniform distribution covering the dispersal period.
```netlogo
;- Assign dispersal
to assign-dispersal
ask patches with [ state != EMPTY ] [
set dispersal-tick (ticks + start-dispersal + random length-dispersal)
...
...
@@ -202,7 +215,7 @@ Each female offspring of each family's `num-offspring` tries to occupy an empty
The target patch of each disperser is set to `S`usceptible. It is assumed that animals infected with Rabies do not disperse.
```netlogo
;- Dispersal
;- Disperse
to disperse
ask patches with [ state != EMPTY and dispersal-tick = ticks ] [
let candidates other patches
...
...
@@ -330,14 +343,20 @@ This is the entrypoint to this "literate program". The blocks referenced by the
### NetLogo file
In the main `.nlogo` file, we only "include" the `.nls` file to allow for the reverse mode. Yarner's reverse mode requires automatically generated comments in the code output to be able to identify the source blocks in this Markdown document. NetLogo, however, supports comments only in the code part, but not in the rest of the content of a `.nlogo` file. Moving the actual model code into the separate `.nls` file resolves this limitation.
In the main `.nlogo` file, we only "include" the `.nls` file to allow for the reverse mode.
Yarner's reverse mode requires automatically generated comments in the code output to be able to identify the source blocks in this Markdown document. NetLogo, however, supports comments only in the code part, but not in the rest of the content of a `.nlogo` file.
The code tab has this single line of content:
Moving the actual model code into the separate `.nls` file resolves this limitation.
The Code tab has this single line of content:
```nlogo
__includes["Code.nls"]
```
Access the file in NetLogo via the `Included files` dropdown in the Code tab.
The file `Model.nlogo` is simply copied from the `nlogo` directory via option `code_files` in the `[paths]` section of the `Yarner.toml`.
This separation of model code (`Code.nls`) and user interface (`Model.nlogo`) also allows to edit the model's UI elements in NetLogo's GUI builder tool, while using Literate Programming for the code.