On Apr 8, 2021, at 5:19 AM, parichehr mandegaran <parichehrm...@gmail.com> wrote:
How do I define memory for turtles in Netlogo that dumps the results of each tick into memory? Each turtle will choose according to its memory in the next ticks.
--
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/52668c98-ddf2-4c1c-b287-9083f17dfde9n%40googlegroups.com.
Hi,
The solution does depend on the case, but typically you will need to make use of at least one turtles-own or <breeds>-own variable to capture the information for each turtle. You could have variables such as previous-xcor, previous-number-of-neighbors etc.
You can also use a list, for example to store a value for each previous tick.
Aaron
--
Aaron Brandes, Software Developer
Center for Connected Learning and Computer-Based Modeling
To view this discussion on the web visit
https://groups.google.com/d/msgid/netlogo-users/3EC6DE0C-EC58-41DD-904B-AD3B91321C98%40gmail.com.
Hi Michael,
I agree that a table makes sense to deal uniformly with multiple crops without repeating code unnecessarily.
Rolling updates also makes sense. I would see that as an enhancement because handling lists is more straight forward.
Although rolling updates just require basic list operations that would not be totally straight forward for some users.
If you want to share some code that illustrates rolling updates and/or using a table as a turtles-own variable I’m sure many netlogo-users would appreciate it.
To view this discussion on the web visit
https://groups.google.com/d/msgid/netlogo-users/CAFkCkGf1jBviZwNtt%3D5VswJorrwzeqKkNrDL15zm5M%3DC5%2BOz4g%40mail.gmail.com.
You could copy and past it and add a setup and go button in the interface, but it won't visually display much useful info,turtles-own[best-prices ; list of best prices by crops [corn soy wheat]last-patch]patches-own[price ; price for a cropcrop ; crop]globals[crops]to setupcacreate-turtles 50[setxy random-xcor random-ycor]set crops ["corn" "soy" "wheat"]ask patches [ set crop one-of crops]ask patches [ set price random 10]ask turtles[set best-prices map [cr -> mean [price] of patches with [crop = cr]] crops]endto goask turtles [ifelse patch-here != last-patch [let alpha .1let cr [crop] of patch-herelet pr [price] of patch-herelet idx position cr cropslet new_prc (item idx best-prices * (1 - alpha) + alpha * pr)set best-prices replace-item idx best-prices new_prcset last-patch patch-here][set heading heading + (random-float 1 - random-float 1)forward .001]]end
Hi Micheal,
Thanks sharing this excellent example of saving and using the memory of multiple previous values using an array.
To view this discussion on the web visit
https://groups.google.com/d/msgid/netlogo-users/CAFkCkGf%2BqTWxG6stkEdtnUx1KgJDf%2ByauLzCAtsoCqNmd6BHxA%40mail.gmail.com.