title: Agents on same patch
body: <p>In this model the boat moves diagonally across the world (which does not wrap, 00 bottom left, max-pycor &amp; max-pxcor 49) and 20 fish move in the opposite diagonal. The model is set up so the boat counts the fish it encounters, and as a double-check each fish counts if it met the boat. It does not matter if the boat does not meet all the fish.</p>
  <p>My problem is that on some (10-15%) of runs, although both agents appear to be on the same patch, the relevant record does not increase, i.e. times that f-count does not increase and other times the b-count might not increase. I have spent time watching the agents closely, and they appear to be on the same patch, but the record does not increase. As a beginner with NetLogo, is there something in the coding of &quot;boats-here&quot;, &quot;fish-here&quot; or &quot;neighbors&quot; that I am overlooking that is related to the xcor/ycor of the agents? Or is the sequence of commands the source of the problem? Thanks for considering my question.</p>
  <pre><code>    breed [boats boat]
      breed [fish a-fish]
  
      boats-own [b-count fuel]            
      fish-own [f-count]                  
  
      to setup
      clear-all                          
      reset-ticks                        
  
      create-boats 1                
        [apply-boat-properties]           
  
       create-fish 20                 
        [apply-fish-properties]
  
      end
  
      to apply-boat-properties            
        ask boats
        [
          set color red
          set size 0.3
          set shape &quot;star&quot;
          setxy min-pxcor max-pycor
          set fuel 710
        ]
      end
  
      to apply-fish-properties                      
        ask fish
        [
          set color blue
          set size 0.3
          set shape &quot;star&quot;
          setxy random-xcor max-pycor
        ]
      end
  
      to go
       if (any? boats with [fuel &lt;= 0 ])           
        [ stop ]
  
        ask boats                                  
        [
          follow-route1
          survey
        ]
  
        ask fish 
        [
          check-if-boat                            
          move
        ]
  
        tick
  
      end
  
  
      to follow-route1                             
        ask boats
      [
          facexy 49 0
          fd 0.05
          pen-down
          set fuel fuel - 1
        ]
      end
  
  
      to survey
        ifelse any? fish-here                        ;; if boat on the same patch as a fish
        [ask fish-here [                             ;; ask the fish on this patch
          if shape = &quot;star&quot;[                         ;; with a &quot;star&quot; shape
            set shape &quot;circle&quot;                       ;; change shape to &quot;circle&quot; shape
         ask boats-here                              ;; ask boat on same patch to increase b-                
        count by 1
              [set b-count b-count + 1]]
          ]
          ]
                                             ;; otherwise
            [ask fish-on neighbors [                   ;; ask fish on neighbouring 8 patches
              if shape = &quot;circle&quot;[                     ;; if the fish has a &quot;circle&quot; shape
                set shape &quot;star&quot; ]                     ;; change that shape to &quot;star&quot; shape
          ]]
        end
  
        to move
          ask fish
         [
            set heading 225
            fd 0.0025
  
          ]
        end
  
        to check-if-boat
          ifelse any? boats-here                             ;; if boats on same patch as the                                     
                                                                 fish
          [
              ask fish-here with [color = blue]              ;; ask the blue fish to change                   
                                                              colour to yellow
            [ set color yellow
              set f-count f-count + 1]                       ;; and increase f-count by 1
          ]
          [ask fish-here with [color = yellow]               ;; otherwise ask fish with yellow 
                                                                 colour to change color to blue
              [set color blue
        ] ]
  
        end
  
         to-report boat-b-count                                ;;Report count of boats with b- 
                                                               count more than 1
         report sum [b-count] of boats with [b-count &gt; 0]
         end
  
         to-report fish-f-count                                ;;Report count of fish with f- 
                                                                 count more than 1
         report sum [f-count] of fish with [f-count &gt; 0]
         end
  
         to-report %fish-counted                               ;;Report count of fish with f- 
                                                                     count more than 1
         report (sum [f-count] of fish / count fish) * 100
         end
  </code></pre>