swarm-support
[Top][All Lists]
Advanced

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

Re: Using the Array type


From: pauljohn
Subject: Re: Using the Array type
Date: Tue, 28 Aug 2001 08:28:54 -0500

Holger Perlt wrote:
> 
> Hello,
> 
> I try to modify the bug (ObserverBug) step by step.
> 
> (a) I introduce two independent species of bugs (Elben, Orks)
> The Elben are put into the usual List. The Orks are defined
> as elements of an Array - in order to have an easy access to
> specific species.
> The compilation goes through - at run time I get an
> STATUS_ACCESS_VIOLATION
> error message.
> The main new codes are inside ModelSwarm.m:
> 
> buildObjects:
> 
> (the 200 as setCount parameter is arbitrary - I wanted to be sure that
> no index range error could occur!)
> 
> bugListOrks = [Array create:  [self getZone] setCount: 200];
> 
>   for(ii =0; ii < 20; ii++){
>   for (y = worldYSize - 8; y < worldYSize + 8; y++)
>     for (x = worldXSize - 8; x < worldXSize + 8; x++)
>       if ([world getObjectAtX: x Y: y] == nil)
>         {
>           aOrk = [Ork createBegin: self];
>           [aOrk setWorld: world Food: food];
>           aOrk = [aOrk createEnd];
>           [world putValue: 3  atX: x Y: y];
>           [aOrk setX: x Y: y];
>           [aOrk setEat: 0 Y: 0];
>           [bugListOrks atOffset : ii put: aOrk];
> 
>         }
>         else
>           [bugListOrks atOffset : ii put: nil];
>   }
> 
> buildActions:
> 
> modelActions = [ActionGroup create: self];
>   [modelActions createActionForEach: bugListElben    message: M(stepp:)
> : bugListOrks];
>   [modelActions createActionForEach: bugListOrks    message: M(step)];
> 
One of the lessons I had the most difficulty with is that the
GNU debugger is your friend.  You run your program and then when
the crash happens, get a back trace to find out which line
caused the crash

There are some graphical interfaces for this, but I always just
end up in the shell

gdb programName
run
bt

In you case, I suspect your bugListOrks has some nil elements in
it, and it always causes a crash when you send a message to a
nil.

I'm no master of GDB, but for my class I prepared these writeups
that might help you:
http://lark.cc.ukans.edu/~pauljohn/ps909/Agent-Based_Models/GDBUsage01.txt
http://lark.cc.ukans.edu/~pauljohn/ps909/Agent-Based_Models/GDBUsage02.txt

If you are using MS Windows, you might note that Marcus Daniels
has an updated version of the gdb program in the fixes part of
the website
-- 
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]