swarm-support
[Top][All Lists]
Advanced

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

[Swarm-Support] Updating Observer swarm with dynamic populations


From: Williamson, Robert J
Subject: [Swarm-Support] Updating Observer swarm with dynamic populations
Date: Mon, 16 Nov 2009 23:18:42 -0500

I am having trouble getting my observer swarm to show Agents that are not 
present when my simulation is initialized. 
I am also having trouble getting my grid2d display to accurately show values. I 
am using Java.

For the grid I more or less copied code from the heatmap display in Heatbugs:

this.resourcesDisplay = new Value2dDisplayImpl
        (this.getZone(), this.worldRaster, this.colormap, 
this.mcs.habitat.getResources());
this.resourcesDisplay.setDisplayMappingM$C(512, 0);
        
However, i just get a black background, with no resource gradient.

My code for displaying Agents is here:
//draw the animats
System.out.println("Drawing Animats");
try {
        this.animatDisplay = new Object2dDisplayImpl
             (this.getZone(), this.worldRaster, this.mcs.habitat.getAnimats(),
                                                new Selector (Animat.class, 
"drawSelf", false));
} catch (Exception e){
        System.err.println ("Exception drawSelf: " + e.getMessage ());
        e.printStackTrace();
}

My habitat class has two discrete2dImpl's one that holds my Agents (Animats) 
and one that holds a resource value. 
getResources returns the one holding the values and getAnimats returns the one 
holding the Agents.

Only my initial few Agents are drawn and updated. My probe shows that the list 
of agents is increasing in length, but they are not being drawn.
I was having trouble getting the ModelSwarm to recognize new Agents but I added 
a "getAgents" call (to update my list) to my schedule in my model schedule and 
that fixed the problem.

This code fixed my model swarm problem:
//gets the current animat list each time
try {
        modelActions.createActionTo$message
                (this, 
                        new Selector (this.getClass(), "getAnimats", false));
} catch (Exception e){
        System.err.println("Exception getAnimats: " + e.getMessage ());
}

When I try making similar calls to update my discrete2dImpl's [like 
habitat.getAnimats()] in the observer swarm's schedule the simulation crashes.

Any ideas?

Thanks for any help,
Robert Williamson
Applied Biology/Software Engineering
Rose-Hulman Institute of Technology
CM# 909
432-294-0088


reply via email to

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