Hiker-modell

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Hiker-modell

PathfinderNew
Hello everyone,

I'm working on a hiker model. Walkers walk in a row and are not allowed to
overtake each other. The first is the slowest hiker.
Do you know of any way I can tell the hikers at the back that once they have
reached their foreman, they should take the speed of this one?

Thank you very much for your help



--
Sent from: http://netlogo-users.18673.x6.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Hiker-modell

guerrin
Hi,


you don't give much detail, however I assume your hikers are turtles all
having the same heading (since they are walking in a row) but different
speeds (i.e. they may move a different number of patches ahead at each
time-step).


Saying once a hiker has reached a preceding one can be reformulated as
once a turtle has got another turtle on the patch just ahead of her.


So, reformulating, saying the turtle behind should move the same speed

as the turtle ahead means the former should always stay behind the
latter, otherwise said she can moves only when there is no turtle on the
number of patches she can cover within a time-step ahead of her.


Based on these above assumptions this is a short programme that, I
think, may achieve your goal:


turtles-own [speed] ; speed is the number of patches a turtle can go at
each time-step (tick)


to Init
   clear-all
   reset-ticks
   ask patches [set pcolor green sprout random 2] ; every patch (green
to be nicer) creates randomly 0 or 1 turtle
   ask turtles [set speed 1 + random 5 set heading 0] ; every turtle
sets randomly her speed between 1 to 5 patches/tick and faces North (so
that they all are following each others in parallel rows)
end


to go
   ask turtles [
     ifelse any? other turtles in-cone speed 0 ; is there any other
turtle ahead of each turtle within a distance of "speed" patches ?
     [fd distance min-one-of other turtles in-cone speed 0 [distance
myself] - 1] ; if true, each turtle goes the distance to the patch of
the closest turtle minus one patch (ie to stay just behind the closest one)
     [fd speed] ; otherwise each turtle goes the distance given by her
"speed"
   ]
   tick
end


Hoping this will help you


cheers


François




Le 03/01/2018 à 13:34, PathfinderNew [hidden email] [netlogo-users] a
écrit :

>
> Hello everyone,
>
> I'm working on a hiker model. Walkers walk in a row and are not allowed to
> overtake each other. The first is the slowest hiker.
> Do you know of any way I can tell the hikers at the back that once
> they have
> reached their foreman, they should take the speed of this one?
>
> Thank you very much for your help
>
> --
> Sent from: http://netlogo-users.18673.x6.nabble.com/
>
>



--

SignatureMail-FG.png (33K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Hiker-modell

guerrin
In addition to my preceding answer, I propose this new program.
In effect, I just realized the previous one didn't account for a turtle
reaching another one should get the same speed as the slowest.
So this new program corrects this forgotten detail.

turtles-own [speed]
to Init
   clear-all
   reset-ticks
   ask patches [set pcolor green sprout random 2]
   ask turtles [set speed 1 + random 5 set heading 0]
end

to go
   ask turtles [
     let closest-turtle-ahead (min-one-of other turtles in-cone speed 0
[distance myself]) ; gets if any the closest turtle ahead of each turtle
     ifelse closest-turtle-ahead != nobody  ; verify if this closest
turtle exists
     [fd (distance closest-turtle-ahead - 1) set speed ([speed] of
closest-turtle-ahead)] ; if so, each turtle goes just behind the closest
one and sets her own speed equal to the other's
     [fd speed] ; otherwise she goes the distance allowed by her own "speed"
   ]
   tick
end

Le 08/01/2018 à 16:50, Francois Guerrin a écrit :

>
> Hi,
>
> you don't give much detail, however I assume your hikers are turtles
> all having the same heading (since they are walking in a row) but
> different speeds (i.e. they may move a different number of patches
> ahead at each time-step).
>
> Saying once a hiker has reached a preceding one can be reformulated as
> once a turtle has got another turtle on the patch just ahead of her.
>
> So, reformulating, saying the turtle behind should move the same speed
> as the turtle ahead means the former should always stay behind the
> latter, otherwise said she can moves only when there is no turtle on
> the number of patches she can cover within a time-step ahead of her.
>
> Based on these above assumptions this is a short programme that, I
> think, may achieve your goal:
>
> turtles-own [speed] ; speed is the number of patches a turtle can go
> at each time-step (tick)
>
> to Init
>   clear-all
>   reset-ticks
>   ask patches [set pcolor green sprout random 2] ; every patch (green
> to be nicer) creates randomly 0 or 1 turtle
>   ask turtles [set speed 1 + random 5 set heading 0] ; every turtle
> sets randomly her speed between 1 to 5 patches/tick and faces North
> (so that they all are following each others in parallel rows)
> end
>
> to go
>   ask turtles [
>     ifelse any? other turtles in-cone speed 0 ; is there any other
> turtle ahead of each turtle within a distance of "speed" patches ?
>     [fd distance min-one-of other turtles in-cone speed 0 [distance
> myself] - 1] ; if true, each turtle goes the distance to the patch of
> the closest turtle minus one patch (ie to stay just behind the closest
> one)
>     [fd speed] ; otherwise each turtle goes the distance given by her
> "speed"
>   ]
>   tick
> end
>
> Hoping this will help you
>
> cheers
>
> François
>
>
> Le 03/01/2018 à 13:34, PathfinderNew [hidden email] [netlogo-users]
> a écrit :
>>
>> Hello everyone,
>>
>> I'm working on a hiker model. Walkers walk in a row and are not
>> allowed to
>> overtake each other. The first is the slowest hiker.
>> Do you know of any way I can tell the hikers at the back that once
>> they have
>> reached their foreman, they should take the speed of this one?
>>
>> Thank you very much for your help
>>
>> --
>> Sent from: http://netlogo-users.18673.x6.nabble.com/
>>
>>
>
> --

--


SignatureMail-FG.png (33K) Download Attachment