I am having trouble understanding an error emerging from two consecutive while loops in a net logo project.
;;;;;;;;;;;;;;;;;;;;;;;;
;;; Global variables ;;;
;;;;;;;;;;;;;;;;;;;;;;;;
globals [it]
;;;;;;;;;;;;;;;;;;;;;;
;;; Breedin agents ;;;
;;;;;;;;;;;;;;;;;;;;;;
breed [houses house]
breed [firms firm]
;;;;;;;;;;;;;
;;; Setup ;;;
;;;;;;;;;;;;;
to setup
clear-all
reset-ticks
create-firms F
create-houses H
;; sets position of the firms in the space for better visualisation
set it 0
while [it < F ]
[ask firm it [
set color yellow
set heading it * 360 / F
fd 5
]
set it it + 1
]
;; sets position of the households in the space for better visualisation
set it 0
while [it < H ]
[ask house it [
set color yellow
set heading it * 360 / H
fd 15
]
set it it + 1
]
When I run the above code I get an error message
firm 0 is not a HOUSE
error while observer running HOUSE
called by procedure SETUP
called by Button 'Setup'
pointing at house it
in the code.
Notice that when I only run the first while loop, everything works fine.
I guess there is something I do not understand in the use of while loops in net logo.
- Why does the second while loop seem to consider that I am calling firms although I asked to call houses?
- Is there a better way to implement while loops in net logo?
Many thanks in advance for you help