swarm-support
[Top][All Lists]
Advanced

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

Customization of "application specific" class. (was Re: Corrupted List


From: Paul Johnson
Subject: Customization of "application specific" class. (was Re: Corrupted List
Date: Fri, 17 Sep 1999 10:18:26 -0500

donalson wrote:
> 
> Does any one recognize this problem?
> 
> 1.)  I create a list of "cell" objects.  One corresponding to each
> discrete 2-D lattice site.
> 
> 2.)  Each "cell" has a list for agents currently residing within.
> 
> 3.)  I create a set of agents.  Each is created with a random X,Y
> designation.
> 
> 4.)  I translate that X,Y into discrete 2-D cooridnates and insert the
> agent into the corrosponding "cell" list.
> 
I don't know what might be wrong, but I have a working example of code
that does the same and you could just use my class for the "multiple
occupancy grids".  I did an update and elaboration of Sven's space
object MoGrid2d and it is called "WrappedListGrid".  When an object is
to be inserted at a spot, it spawns a "list wrapper" object to receive
the object into a list.  The list wrapper is designed so you can
retrieve objects, get a list count, and you add any user specific
functionality. The user specific part of the application can be
specified in the file called "ListWrapper.m" in the second part, where
the class ApplicationSpecific is defined.

http://lark.cc.ukans.edu/~pauljohn/Swarm/MySwarmCode/cultureWrappedListBatchRaster-990823.tar.gz

I've got another application using the same class called "protest". 
 
http://lark.cc.ukans.edu/~pauljohn/Swarm/MySwarmCode/protest-990823.tar.gz

I was intending to package up my revision of the multiple occupancy grid
(3  classes, WrappedListGrid, ListWrapper, and ApplicationSpecific) and
put it in SFI's ftp site.  Before I do, I wondered if there was a more
elegant way to handle the customization of the ApplicationSpecific. 
Currently, in the file ListWrapper.[hm], I have the general purpose
functions in a class called ListWrapper, which is inherited by
ApplicationSpecific. ApplicationSpecific objects get inserted into the
grid.

Here is a sketch of the hierarchy


      Swarm's Grid2d                         SwarmObject
          |                                     |
          v                                     v
         WrappedListGrid2d                    ListWrapper
                                                |
                                                v
                                              ApplicationSpecific

Inserting an object into the WrappedListGrid2d causes an
ApplicationSpecific object to be created and placed on the Grid.
Additional objects inserted there are added into the list inside
ApplicationSpecific.  The WrappedListGrid2d has code to create, destroy,
recycle, objects of class ApplicationSpecific.  The general purpose
functions of the cells, to create lists, to add objects, and such, are
in the ListWrapper class, and so ApplicationSpecific inherits those
methods.  THen the ApplicationSpecific class does things like respond to
"drawSelf" or "reportAverageOfMembers" or any such thing that acts on
all the objects that have been put into that cell's list.

Gee, writing it down this way, I can't remember what I thought was
ungainly about it. At worst, I should just put the shell of
"ApplicationSpecific.[hm] in files by themselves.  These files are
available here if you want to just look at them:

http://lark.cc.ukans.edu/~pauljohn/Swarm/MySwarmCode/WrappedListGrid2d-990817.tar.gz

-- 
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]