title: while loop debugging in netlogo
body: <p>I am having trouble understanding an error emerging from two consecutive while loops in a net logo project. </p>
  
  <pre><code>;;;;;;;;;;;;;;;;;;;;;;;;
  ;;; 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 &lt; 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 &lt; H ]
    [ask house it [
        set color yellow
        set heading it * 360 / H
        fd 15
        ]    
    set it it + 1
    ]  
  </code></pre>
  
  <p>When I run the above code I get an error message</p>
  
  <pre><code>firm 0 is not a HOUSE
  error while observer running HOUSE
    called by procedure SETUP
    called by Button 'Setup'
  </code></pre>
  
  <p>pointing at <code>house it</code> in the code. </p>
  
  <p>Notice that when I only run the first while loop, everything works fine. </p>
  
  <p>I guess there is something I do not understand in the use of while loops in net logo. </p>
  
  <ul>
  <li>Why does the second while loop seem to consider that I am calling firms although I asked to call houses? </li>
  <li>Is there a better way to implement while loops in net logo?</li>
  </ul>
  
  <p>Many thanks in advance for you help</p>