[starlogo-users] Traffic simulation question

Pablo E. Coll pecoll at dc.uba.ar
Mon Aug 9 00:38:50 EDT 2004


Dear Starlogoers,
                 I am new using Star Logo.
I am trying to simulate a single traffic lane with a
source of uniform random vehicles in the beginning of
the lane and a sink of vehicles on the end.
All attempts to produce such behaviour where unsuccessful.

this is part of my last code
I create cars with frecuency aproximately 1/3
and then put them with, this two lines, in the beginning of the lane
  seth-of lastCar 90
  setx-of lastCar -99
But after short number of cycles something goes wrong and no more cars
are born, or at least, no more cars cames from the beginning of the lane

to go
createCars
ask-turtles[
  moveDemon
  collisionDemon
  radarDemon
  killCars
  ]
end

to createCars
if (random 100) < 33 [
  create-turtles 1
  setlastCar lastCar + 1
  setc-of lastCar yellow
  seth-of lastCar 90
  setx-of lastCar -99
  setstepSize-of lastCar 1 + (0.1 * random 16)
  setspeedLimit-of lastCar 3 + random 8
  setdangerDistance-of lastCar 4
 ]
end

I will be very thankful for any advice on this question.
If some one wants to see all my code please write me.
Thanks in advance.
++Pablo;




More information about the starlogo-users mailing list