swarm-support
[Top][All Lists]
Advanced

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

Re: Simple Simulation problem


From: Paul Johnson
Subject: Re: Simple Simulation problem
Date: Tue, 02 Jul 2002 05:46:49 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020606

It worked better for you to post the file and refer us to it. Please don't attach binaries that get sent to the whole list.

I have your new simulation.zip and I'm working with the system where I built swarm and the irritating c++ dependency is fixed. When I run your program, I see this:

$ javaswarm StartSimulation
SimpleBug number 1 has been created at 40, 0
SimpleBug number 2 has been created at 40, 80
Exception in thread "main" java.lang.NullPointerException
        at ObserverSwarm.buildObjects(ObserverSwarm.java:85)
        at StartSimulation.main(StartSimulation.java:14)

Which is the system's way of telling you that you sent a message to a nil object. If I were you, I would find out how to run a debugger. Today, I'm not able to get gdb to work as the SwarmFaq describes, but I can get to jdb, and it points back at line 85 of ObserverSwarm.java

Note you are giving these instructions to objects that are not yet created
      a1bug.setBugColor((byte)1);
      a2bug.setBugColor((byte)2);


To make this work, you either have to set the colors inside ModelSwarm itself, which you can do by moving those two lines into ModelSwarm right after your 2 agents are created, or make the variables public and talk to them directly from Observer, as in:
    modelSwarm.a1bug.setBugColor((byte)1);
    modelSwarm.a2bug.setBugColor((byte)2);


After that change, I see a raster that's not quite what you intend--not updated or drawn on properly--and terminal output like

$ javaswarm StartSimulation
SimpleBug number 1 has been created at 40, 0
SimpleBug number 2 has been created at 40, 80
Agent 1 is at 40, 79
Agent 2 is at 41, 79
Agent 1 has found Content of 1 at 41, 0
Agent 1 is at 41, 0
Agent 2 is at 42, 78
Agent 1 has found Content of 1 at 41, 0
Agent 1 is at 41, 0
Agent 2 is at 41, 77
Agent 1 is at 41, 1
Agent 2 has found Content of 1 at 40, 77
Agent 2 is at 40, 77

I'd suggest you join the Swarm Development Group if you want me to do any more of this kind of detailed work.


Trushar Panchal wrote:
Hi Paul,

Thanks for your advise. I am sending you the zip file as you requested. Also I missed to initialise the file Agent1/2.java with int a=0; which i have done. I use Win 2000 and java. It compiles without any problems and comes up with the Control Panel but the Display window and the Probe Windows are not coming up. Once I click 'Start' this is the two output i get.



--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.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]