title: Netlogo Mekka Model - need directions
body: <p>I'm working on this assignment for my university with Netlogo and I'm really stuck.
  I just started out using Netlogo and I'm trying to recreate Mekka, together with some pilgrims. </p>
  
  <p>I've been trying out a lot of different codes, adding new ones, trying it out, deleting some, but this is what I came up with this far: </p>
  
  <pre><code> turtles-own
  [direction                ;;  1 follows right-hand wall, -1 follows left-hand wall
   way-is-clear?            ;; reporter - true if no wall ahead
   checked-following-wall?]
  
  globals [halfedge]
  
  breed [agents agent ] 
  
  agents-own [ around visible ]
  
  to setup
    create-agents 500 [
      set color green
      set size 2
      ; distribute agents randomly
      setxy pxcor = halfedge pycor = halfedge 
      set heading random 360
      ; ensure that each is on its own patch
      while [any? other agents-here] [ fd 1 ]
  
    ]
  end
  
  to bounce 
    if [pcolor] of patch-at dx 0 = blue [
      set heading (- heading)
    ]
    if [pcolor] of patch-at 0 dy = blue [
      set heading (180 - heading)
    ]
  end
  
  to go 
    ask agents [ count-those-around ]
    ask agents [ move ]
  end
  
  ; store the number of agents surrounding me within
  ; local-radius units
  ; and the agents that I can see within visible-radius
  
  to count-those-around
    set around count agents with [self != myself] in-radius 
    local-radius
    set visible agents with [self != myself] in-radius 
    visible-radius
  end
  
  to move 
     ;; turn right if necessary
    if not wall? (90 * direction) and wall? (135 * direction) [ rt 90 * direction ]
    ;; turn left if necessary (sometimes more than once)
    while [wall? 0] [ lt 90 * direction ]
    ;; move forward
    fd 1
  end
  
  ; face towards the most popular local spot 
  to face-towards
    face max-one-of visible [around]
  end
  ; face away from the most popular local spot
  to face-away
    set heading towards max-one-of visible [around] - 180
  end 
  
  to setup-center
     clear-all
    set halfedge int (edge / 2)
    ask patches[
      if (pxcor = (- halfedge) and pycor &gt;= (- halfedge) and pycor &lt;= (0 + halfedge) )
        [set pcolor blue]                                ;; ... draws left edge in blue
      if ( pxcor = (0 + halfedge) and pycor &gt;= (- halfedge) and pycor &lt;= (0 + halfedge) )
        [set pcolor blue]                                ;; ... draws right edge in blue
      if ( pycor = (- halfedge) and pxcor &gt;= (- halfedge) and pxcor &lt;= (0 + halfedge) )
        [set pcolor blue]                                ;; ... draws bottom edge in blue
      if ( pycor = (0 + halfedge) and pxcor &gt;= (- halfedge) and pxcor &lt;= (0 + halfedge) )
        [set pcolor blue]                                ;; ... draws upper edge in blue
      ]
  end
  </code></pre>
  
  <ul>
  <li>The idea is that first, a square is setup resembling the kaaba. </li>
  <li>After that, the turtles are set up. </li>
  <li>They are supposed to all walk around the wall in a counter-clockwise direction.</li>
  <li>There's supposed to be one 'leader' that would lead all the pilgrims around the kaaba. </li>
  </ul>
  
  <p>Right now the kaaba is successfully drawn, the only problem is that turtles are not supposed to be spawn in there or run into it (therefore the bump code). 
  Also, they are randomly going around, and I have no idea how to make them move in a Counter-Clickwise formation, following one differently coloured leader. </p>
  
  <p>Could any of you guys help me out? I would be eternally thankful!</p>