title: Trouble with bracket placement and the ifelse and let commands in Netlogo
body: <p>I am having trouble with bracket placement and the ifelse and let commands in Netlogo. </p>
  
  <p>I have a variety of different conditions relating to patches-own (envi) and turtles-own (niche-opt, niche-range) variables that determine a local-variable (multi), that will then be used to determine the probability of reproduction.</p>
  
  <p>Turtles have a variable niche-opt, if this matches the patch variable envi then the local variable multi = 1</p>
  
  <p>If niche-opt != envi but envi is within niche-opt +- niche-range (turtle variable, integer ranging from 1 - 3) then multi = 0.8</p>
  
  <p>And finally if envi is outside niche-opt +- niche-range then multi = 0.2    </p>
  
  <p>So the local variable "multi" can be one of three values (1,0.8 or 0.2), which is then multiplied with a turtles-own variable (trait-2) and used to determine the probability of hatch occurring.</p>
  
  <p>My issue is that in the line of code:</p>
  
  <pre><code>if random-float 100 &lt; (multi * trait-2 * 100)
  </code></pre>
  
  <p>comes up with the error "nothing named multi defined". I am sure the issue is to do with my bracket placements as let creates a local variable, but I cannot figure out if I need to add more brackets or just move the ones I have.     </p>
  
  <pre><code>to go
     ask turtles [
     reproduce  
     ]
  end
  
  to reproduce  
    ifelse niche-opt = envi  
    [let multi 1] 
    [ifelse envi &gt;= (niche-opt - niche-range) and envi &lt;= (niche-opt + niche-range)
    [let multi 0.8]
    [let multi 0.2]
    ]
  if random-float 100 &lt; (multi * trait-2 * 100)
  hatch 1 
  end
  </code></pre>