squirm | Scala API for JQuery Mobile | Frontend Framework library
kandi X-RAY | squirm Summary
kandi X-RAY | squirm Summary
Scala API for JQuery Mobile
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of squirm
squirm Key Features
squirm Examples and Code Snippets
Community Discussions
Trending Discussions on squirm
QUESTION
I wish to accomplish the following with a NetLogo simulation:
Create a bounded circular world with a radius of 10 cm and three zones
- Outer Zone: define an annulus 1.5 cm from the world boundary (red)
- Inner Zone: circle with radius = 8 cm (gray)
- Forbidden Zone: off-limits for all turtles (black)
Locomotory Behavior
- A turtle has predefined turning angles and movement lengths given in the code below
- However, I would like to include the probability for a turtle to pause for some normally-distributed duration of n ticks
Edge Following Behavior - Thigmotaxis
A turtle may enter the Outer Zone at will, but the following rules govern its behavior while there:
- A turtle may escape the Outer Zone if it crosses into the Inner Zone.
- However, the probability for a turtle to remain within the Inner Zone equals [some normally-distributed probability] per tick.
Generate a position report (2D coordinates) for each turtle on a per tick basis
Export this report(s) as a CSV or TXT file
My code is based on the "Random Walk Example" from the NetLogo library and includes "per tick" rules such as turning angles, movement lengths. I tried to implement the probability of a turtle to pause per tick, but I don't know how to incorporate a duration of n ticks. Inner and outer regions are differently colored patches. Then, we can base the turtle behavior on if pcolor = red [commands go here]
. Also, When a turtle hits the world boundary, it tends to become stuck as it squirms to find an escape angle. Rather, is it possible to allow the turtle to "turn into" the curved wall of the world whilst avoiding the Forbidden Zone (black patch color)? Finally, for data export, it is easy enough to save the Commmand Center
output, but it is not formatted conveniently for analysis i.e. x, y coordinates in separate columns, etc.
ANSWER
Answered 2020-Oct-28 at 13:59Technically this is a bunch of (admittedly related) questions, rather than a single question (as is preferred on StackOverflow). But I'll see if I can make a coherent answer.
Here is a runnable version of the final code with all the changes for anyone interested.
First, the simplest way to control turtle movement is to use the patch-ahead
primitive to check where they would be moving to, and then changing their destination if necessary. This is easiest when using forward 1
instead of a random amount, so I start with that. I then use face one-of neighbors with [pcolor = red]
to get the turtle facing a "good" patch. Again, that only works with the forward 1
.
I also added __change-topology false false
to prevent a turtle from wrapping around the world, as some of the patches do touch at the edges.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install squirm
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page