[starlogo-users] Need help

Zara Phang zphang at epcc.ed.ac.uk
Thu Jul 12 12:11:46 EDT 2007


I've fixed my problem on the 7th rewrite!  I did try the moving forwards 
and smelling, but realised I would always get some sort of ambiguity about 
whether my neighbours were ahead or behind me.

My fix was to have each agent compare its x coordinate against all other 
agents' x coordinate.  For anyone who's interested I did this by creating 
a check which was done thus:

create a Move variable (true if it should move, false if it doesn't),

create a procedure that checks whether it should move each time.
set Move variable to true, then
make outside loop variable to count what iteration it is on

repeat (count everyone) times, do
 	if (xcoordinate of current iteration = xcor + number to get to next
space)
 	then set Move variable to false, increase outside loop variable.

and run this each time *after* moving (so some initial setup is needed).

If that was really confusing (I can see how it could be) and anybody would 
like to look at the code of the whole program you can just send me an 
e-mail.

thanks,
Zara

On Wed, 11 Jul 2007, Eric Klopfer wrote:

> I am not quite sure I understand.  Perhaps you could attach your project.
>
> But in TNG each turtle actually runs the entirety of its code before the next 
> agent gets to run theirs.  so an agent could have code that says forward 1, 
> smell 1, back 1, and it will detect another agent that is just over 1 space 
> ahead of it.  That other agent won't run its code until this agent is done. 
> That is a change from the older StarLogo and should make doing these kinds of 
> things a bit easier.
>
> Eric
>
> On Jul 11, 2007, at 12:41 PM, Zara Phang wrote:
>
>> Hi Eric
>> 
>> Thanks for your prompt and helpful reply!
>> 
>> Unfortunately I am only dealing with one breed of agent, so when I move 
>> forward, *all* agents move forward, hence there will never be something 
>> there for them to smell!
>> 
>> I was thinking that I might be able to do this if I could get them moving 
>> forwards one at a time, but as I am having them stay there if there is not 
>> an agent in front of them (I am doing a very simple traffic simulation), if 
>> there is an agent directly behind the first agent that checks and then 
>> moves, the agent would not know the first agent was there before and will 
>> just move into the space.
>> 
>> On Wed, 11 Jul 2007, Eric Klopfer wrote:
>> 
>>> Check out the way that the sonics smell the marios in the sonics vs. mario 
>>> demo game that comes with TNG.  Essentially each round the sonics move one 
>>> step in each direction and smell the number of marios that they see there.
>>> 
>>> You could do something similar where you had the agent move only forward 
>>> and smell and then move back.
>>> 
>>> We'll have more advanced processing of smell in an upcoming release.
>>> 
>>> Eric
>>> 
>>> On Jul 11, 2007, at 11:33 AM, Zara Phang wrote:
>>> 
>>>> Hello everyone!
>>>> I'm trying to do some cellular automata on StarLogo and was wondering if 
>>>> someone could help me with something I think should be quite simple but I 
>>>> haven't managed to do yet!
>>>> I've basically got agents lined up on an x axis randomly placed by y, so 
>>>> maybe like this:
>>>> xxx x x     x xxx    x xxx
>>>> and I want to figure out whether each agent has another agent in front of 
>>>> them.  I'm currently using the 'smell' feature under 'Other Agents' with 
>>>> a radius of 1, which tells me that whether there is an agent either side 
>>>> of it, so I think I am halfway there!  I have tried the 'smell with' with 
>>>> a radius of 1 and a condition of (xcor of who > xcor) but this doesn't 
>>>> seem to work.
>>>> Does anybody have any ideas what is going wrong and how I can fix this?
>>>> Many thanks,
>>>> Zara
>>>> _______________________________________________
>>>> starlogo-users mailing list
>>>> starlogo-users at media.mit.edu
>>>> http://education.mit.edu/mailman/listinfo/starlogo-users
>>> 
>


More information about the starlogo-users mailing list