Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would you create turtles on a set patch with a predetermined velocity and heading?

Tags:

netlogo

I have tried using sprout to create patches on a certain patch but, by looking up in the Netlogo dictionary, I have found out that this command creates turtles with random velocities and headings. Similarly (crt) only creates the turtles at the origin and I presume that by defining coordinates you could vary the places where the turtles were spawning. The problem with both these options is that they limit the limit the users ability to create and test road networks for themselves in the U.I and I seek a command or a snippet of code that will allow me to create turtles with set headings and speeds on a set patch of a certain colour. Here is an example of the code I am using:

   globals[road? ]
   turtles-own [speed]
       breed[cars car]
     breed [sinks sink]
   to setup
  clear-all
  ask patches [set pcolor green ]
  set-patch-size 50
  if mouse-down?
 [ ask patch mouse-xcor mouse-ycor [ edit-world-primary ]
 ] 

 end
   to go
 if mouse-down?
 [ ask patch mouse-xcor mouse-ycor [ edit-world-primary ]
  ] 
 edit-world-secondary
ask turtles-on patches with[pcolor = blue][set heading 90 ]
ask patches [if pcolor = blue [sprout 2 ] ]
 ask turtles[   
 set shape"car"
 set color white
 set speed 90]
 ask turtles[ rt 0 fd speed set heading 90 ]

 end

Any help in modifying the commands I use within my code would be greatly appreciated.

like image 345
AKarr Avatar asked Dec 15 '25 06:12

AKarr


1 Answers

Ask patches with[pcolor = blue ][sprout 5 [set heading 90 set velocity .1]]

Has all the parts you seem to be looking for.

To make the turtles move at their velocities.

To go
   Ask turtles [fd velocity]
End

Set that go to forever and your turtles will zip along.

like image 134
King-Ink Avatar answered Dec 16 '25 22:12

King-Ink



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!