how can i make a code : i need to know how mutch time one agent (turtle) keep level of wealth

23 views
Skip to first unread message

ABDERRAHIM HADDAD

unread,
Jun 4, 2024, 3:50:02 PMJun 4
to netlogo-users
Hi ;
please i need help;
my question is :
how can i make this code : I need to know how mutch time (tick) one agent (turtle i) keep level of wealth ?
for example i make 500 turtles (i need to now how many turles keeped a level of wealth (for example 100) for 200 ticks (equale for me one year)

thx

Pradeesh Kumar K V

unread,
Jun 6, 2024, 9:33:12 AMJun 6
to netlogo-users
You could try the following code. In this code, I have assigned 100 turtles with wealth between  0 and 99. The code will count the number of consecutive ticks for which the wealth of a turtle remains above 50. If the total count of ticks equals or exceeds 200, then the turtle variable 'counter' is set to 1.

At the end of the run, you can count the number of turtles with 'counter' = 1.

turtles-own [counter wealth time-counter]

to setup
ca
reset-ticks
create-turtles 100
[
set counter -1
set wealth random 100
]
end

to go
;check if wealth is equal to or greater than 50. If yes set time-counter time-counter + 1
; If wealth is less than 50, set time-counter = 0
ask turtles
[
ifelse wealth >= 50 and counter = -1
[
set time-counter time-counter + 1
]
[
set time-counter 0
]

;if time-counter >= 200, set counter to 1
if time-counter >= 200
[
set counter 1
]
]
tick
end
Hope this helps.

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/f038e26a-75dd-4484-b09e-1c4e58d28f24n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages