C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# Netlogo: How can I obtain the accumulate value in Netlogo?

## Netlogo: How can I obtain the accumulate value in Netlogo? Tag : development , By : user161314 Date : January 12 2021, 08:33 AM

fixed the issue. Will look into that further that's much better, thanks- I can now run the code no problem. However, I still don't think I understand what you are wanting cumulative-sum to actually count. Are you just looking for the total number of turtles, including both those still alive and the ones that have died? If so, I think it's just a matter of moving your set cumulative-sum cumulative-sum + 1 line. For example:
EDIT:
``````globals [num-turtles cumulative-sum average-time number-dead ]
turtles-own [count-up]

to setup
clear-all
set num-turtles 5
reset-ticks
end

to go

if count turtles < num-turtles [
sprout 1 [
set count-up 0
]
]
]

if (count turtles > 0) [
if count-up >= 6 [
die
]
]
]

ask turtles-on patch 0 0 [
set count-up count-up + 1
]

set cumulative-sum cumulative-sum + count turtles

tick
end
``````

Share :

Tag : development , By : jazzyfox
Date : March 29 2020, 07:55 AM
To fix the issue you can do random 20 might return 0 or 1, and then the first thing you do to move-distance inside the loop is subtract 1 from it, so the move-distance = 1 check will fail because it's already below 1.
Try replacing move-distance = 1 with move-distance <= 1, and/or replace random 20 with 2 + random 18.

Tag : development , By : Igor Carron
Date : March 29 2020, 07:55 AM
Any of those help You need to store the lagged value (e.g., in a turtle attribute). For example,
``````turtles-own [x xlag]

to setup
ca
crt 1 [set x random-float 1.0]
end

to go
ask turtles [set x random-float 1.0]
ask turtle 0 [show x - xlag]
end
``````

## Netlogo: Can Netlogo set up an infinite number of turtles for only one specific patch?

Tag : development , By : ganok_tor
Date : March 29 2020, 07:55 AM
I hope this helps . As per Bryan's answer, there is no theoretical restriction on the number of turtles in a single patch, although your computer will have a limit- the more turtles in your model (on any patch) the more memory your model will use. So the short answer is, as far as I know, there is no way to just say to Netlogo, "Spawn infinite turtles on this patch."
If, however, by infinite you really just want enough turtles that you won't run out of them for specific interactions, you could probably get by either by just spawning a large number on that patch or by just sprouting more as needed (my preference).
``````to setup
ca
reset-ticks
sprout 10000
]
print count turtles-here
]
end
``````
``````to setup
ca
reset-ticks
infinite-sprout
source-sprout

end

to go

ask turtles with [ color = red ] [
fd 0.5
if any? ( turtles-on patch-ahead 1 ) with [ color = blue ] [
tie
]
set color green
]
]
ask turtles with [color = green] [
if pycor = max-pycor [
die
]
die
]
]

infinite-sprout
source-sprout
tick

end

to source-sprout
if not any? turtles-here and random 3 = 1 [
sprout 1 [
set shape "arrow"
set color red
]
]
]
end

to infinite-sprout
if count turtles-here < 1000 [
sprout ( 1000 - count turtles-here) [
set shape "circle"
set color blue
]
]
]
end
``````

## How do I translate my code from Netlogo to Netlogo Web? ('TO or TO-REPORT expected' error)

Tag : development , By : ERaubenheimer
Date : March 29 2020, 07:55 AM

## Is NetLogo too slow for big simulations? How can I speed up a NetLogo model?

Tag : performance , By : Aires
Date : March 29 2020, 07:55 AM