Folks,
I am new to MASON and learning Java as well, but a grizzled agent-based modeler. I am leaning heavily on the tutorial in the manual (Student cliques), but would be in a better place if I could reference the code from the other tutorials. Are those available?
I'm hesitant to post a basic question to a list with sparse and advanced questions, but here goes. I am seeking to add two unrelated agents to a simulation and a single dispaly. Ultimately I will build a model with several agent types and several displays.
I've adopted the language in the example, and in setupPortrayals i have included the code below (potato producers and potato distributors as agents). The code checks out, but gives a runtime "potatoDistributors cannot be cast to potatoProducers" error. Searches suggest that is because the agents differ, but I do need them to have different attributes.
I wish to add two agent types to a single display, and have them interact, such as buy and selling potatoes between them. I have searched for the code for the tutorials, but found messages on Github saying they have been removed. Are old examples available that will show me general techniques? I suspect "Asteroids" or "Keep-away Soccer" would go a long way to clarifying things for me.
Thank you for any help, and pardon if this query isn't correctly formatted,
Randy Boone
***************
ContinuousPortrayal2D landPortrayal = new ContinuousPortrayal2D();
ContinuousPortrayal2D potatoDistributorsPortrayal = new ContinuousPortrayal2D();
*************
if (cSystem.includePotatoes == true) {
PotatoProducers potatoProducers = (PotatoProducers) state;
landPortrayal.setField( potatoProducers.land );
landPortrayal.setPortrayalForAll(new MovablePortrayal2D(
new CircledPortrayal2D(
new LabelledPortrayal2D(
new OvalPortrayal2D()
{ public void draw(Object object, Graphics2D graphics, DrawInfo2D info)
{ PotatoProducer potatoProducer = (PotatoProducer)object;
paint = new Color(0, 0, 255);
super.draw(object, graphics, info);
} }, 5.0, null, Color.black, false), 0, 5.0, Color.green, true)));
}
PotatoDistributors potatoDistributors = (PotatoDistributors) state;
potatoDistributorsPortrayal.setField(potatoDistributors.land2);
potatoDistributorsPortrayal.setPortrayalForAll(new MovablePortrayal2D(
new CircledPortrayal2D(
new LabelledPortrayal2D(
new OvalPortrayal2D()
{ public void draw(Object object, Graphics2D graphics, DrawInfo2D info)
{ PotatoDistributor potatoDistributor = (PotatoDistributor)object;
paint = new Color(0, 255, 0);
super.draw(object, graphics, info);
} }, 5.0, null, Color.black, false), 0, 5.0, Color.green, true)));
}
|