I was working on a NetLogo project for school, when I ran into this issue with my NetLogo code. When I first made the code, I put the procedure death-check in the ask patches command with this being my program:
patches-own [num-live]
to setup ;;this sets up all of the code
clear-all
ask patches [
if random 100 < percent-alive [
cell-birth
]
]
reset-ticks
end
to go
ask patches [
set num-live count neighbors with [
pcolor = yellow
]
death-check
]
tick
end
to cell-birth
set pcolor yellow
end
to cell-death
set pcolor black
end
to death-check
if num-live < 2 or num-live > 3 [
cell-death
]
if num-live = 3 [
cell-birth
]
end
Now if I put the ask patches inside the procedure, it comes out with a different output. Here is what I changed inside the code:
to go
ask patches [
set num-live count neighbors with [
pcolor = yellow
]
]
death-check
tick
end
to death-check
ask patches [
if num-live < 2 or num-live > 3 [
cell-death
]
if num-live = 3 [
cell-birth
]
]
end
What I was wondering was why did this small change make such a big difference for my program?