swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Duplicate objects in a grid2d?


From: Paul E. Johnson
Subject: Re: Duplicate objects in a grid2d?
Date: Sun, 04 Jun 2000 10:31:09 -0500

> On the raster graph, I see agents displayed as I would expect. The
> only problem there is that I cannot see the probe of some agents at
> the border (error message that coordinates are wrong ?!?)

Don't forget that if worldSize is 10, you can only put agents on squares
0 through 9. That's the most common mistake my students and I make.

The  grid will let you put agents "off the edge", and then you get all
kinds of weird stuff.  As I recall, inside the swarm library, the grid,
it is a long piece of memory that is accessed through offsets. If you
have a 10x10 world, it allocates 100 pieces of memory and then macros
are used to translate your coordinates (3,2) into a position in that
array.  You say "tell me what's at 3,2" and it calculates "hmm, go 4
rows worth of spaces then three more spaces", to the 43rd position.  You
should eventualy start to get seg faults when you place objects at
(worldSize,worldSize), as these are actually off the edge on both
dimensions. But with (worldSize,2) you don't actually go off the edge,
you end up at a position that is adjacent in memory, but not what you
expect.
> 
> Now, the bigger problem is that when I ask the grid2d (world) to tell
> me what it has at each position, I get some players twice (at
> different positions):
> at (0,0) nil
> at (0,1) there is player 0...
> at (6,6) there is player 3...
> at (6,8) there is player 3...
> at (7,1) there is player 2...
> at (7,6) there is player 1...
> at (7,8) there is player 1
> at (8,0) there is player 0
> .....
> 
> -  this happens at the creation of players, and just before that, the
>    grid2d only contains "nil" objects
Note you get the double when a player is at the outside edge.  Possibly
linked to previous issue.


If you get the initial positions correctly within the world, then the
only way I have seen this problem happen is if you forget to put a "nil"
where the agent is when you move them to another space. THen the world
has two locations for an agent.  If you run the simulation  a few more
steps, you should start to see more and more duplicates.

-- 
Paul E. Johnson                         email: address@hidden
Dept. of Political Science              http://lark.cc.ukans.edu/~pauljohn
University of Kansas                    Office: (785) 864-9086
Lawrence, Kansas 66045                  FAX: (785) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]