'Agents on same patch

In this model the boat moves diagonally across the world (which does not wrap, 00 bottom left, max-pycor & 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.

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 "boats-here", "fish-here" or "neighbors" 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.

    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 "star"
        setxy min-pxcor max-pycor
        set fuel 710
      ]
    end

    to apply-fish-properties                      
      ask fish
      [
        set color blue
        set size 0.3
        set shape "star"
        setxy random-xcor max-pycor
      ]
    end

    to go
     if (any? boats with [fuel <= 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 = "star"[                         ;; with a "star" shape
          set shape "circle"                       ;; change shape to "circle" 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 = "circle"[                     ;; if the fish has a "circle" shape
              set shape "star" ]                     ;; change that shape to "star" 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 > 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 > 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


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source