MASON-INTEREST-L Archives

March 2012

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Tue, 20 Mar 2012 10:00:48 -0400
Content-Type:
multipart/mixed
Parts/Attachments:
text/plain (605 bytes) , CoordinationGameWithUI.java (2148 bytes) , CoordinationPlayers.java (1324 bytes) , CoordinationPlayer.java (1168 bytes) , text/plain (3707 bytes)
Randy, I am attaching some revised classes for you.  So here's the thing.  MASON assumes that the model object and the portrayal of that object can be entirely separated.  It doesn't have to be that way, but it's a common scenario.

In your code it seems that you're trying to have the model object (CoordinationPlayer) also portray itself.  So I've modified the code to get that approach working.  Your agents are now drawing their chosen color.

BTW, I suggest that general discussion regarding GMU etc., should be kept off the list as it's got lots and lots and lots of non-GMUers on it.  No biggie.




Sean On Mar 20, 2012, at 7:39 AM, Randolph Latimer wrote: > Thanks Richard, > I'm trying to have each agent portrayed with it's own particular color. I tried your code suggestion (I may not be doing something correct), and all the CoordinationPlayer agents have the same color, either red or yellow, in this case. > I'd like a blend of different colored agents portrayed, and the color is determined within the single agent class, like CoordinationPlayer. > Thanks for your help, > Randy Latimer > > On 20.03.2012 04:20, Richard O. Legendi wrote: >> Hi Randy, >> >> I'm a bit unsure if it helps you, but you can simply subclass >> _RectanglePortrayal2D_ directly with _CoordinationPlayers_, something >> like the following code (haven't tested). >> >> This way you'll have a _color_ variable (called _paint_) by default. >> >>> public class CoordinationPlayer >>> extends RectanglePortrayal2D >>> implements Steppable { >>> >>> private static final double DIAMETER = 6.0; >>> >>> public CoordinationPlayer() { >>> super(DIAMETER); >>> paint = (random.nextInt(2) == 0) ? Color.RED : >>> Color.YELLOW; >>> } >>> >>> ... >>> } >> This way you don't need the magic in the _setupPortroyals()_ >> function. >> >> HTH, >> Richard >> >> -- >> Richard O. Legendi >> Software developer >> Intelligent Applications and Web Services >> AITIA International, Inc. >> http://people.inf.elte.hu/legendi/ [2] >> >> On 2012.03.19. 14:53, Randolph Latimer wrote: >> >>> I'm starting out again with Mason and will appreciate some help with >>> what I expect are fairly simple questions. >>> >>> I'm transferring a Coordination Game model from Ascape to Mason. >>> The Ascape code is described here, if anyone's interested - >>> http://ascape.sourceforge.net/manual/Section3.html [1] >>> >>> In Mason, I'm using the Schoolyard model as a starter. >>> In Coordination Game, each agent needs a variable for its color. >>> I'm trying something like this (I don't think I'm implementing >>> Mason SimpleColorMap correctly): >>> >>> public class CoordinationPlayer implements Steppable >>> { >>> //public static final double MAX_FORCE = 3.0; >>> protected SimpleColorMap colormap = new >>> SimpleColorMap(0,1,Color.black,Color.white); >>> public Color color; >>> public MersenneTwisterFast random = new >>> MersenneTwisterFast(); >>> >>> public CoordinationPlayer() >>> { >>> if (random.nextInt(2) == 0) >>> color = Color.red;// colormap.getColor(.2); >>> else color = Color.yellow; //colormap.getColor(.7); >>> } >>> >>> public Color getColor() >>> { >>> return color; >>> } >>> >>> In CoordinationGameWithUI, - the color is displayed here, in this >>> hybrid code from the Schoolyard model. >>> I'm trying to set the color with setPortryalForClass, where each >>> class object has its own color. >>> This isn't working correctly: >>> >>> public void setupPortrayals() >>> { >>> CoordinationPlayers students = (CoordinationPlayers) >>> state; >>> >>> yardgridPortrayal.setField(students.yardgrid); >>> I'M TRYING TO SET THE COLOR HERE: >>> >>> yardgridPortrayal.setPortrayalForClass(CoordinationPlayer.class, >>> new >>> RectanglePortrayal2D(CoordinationPlayer.getColor(),true)); //new >>> >> >>> RectanglePortrayal2D(Color.red,true)); >>> yardgridPortrayal.setPortrayalForNull(new >>> RectanglePortrayal2D(Color.blue,true)); >>> >>> Thanks for any help - >>> Randy Latimer >> >> >> Links: >> ------ >> [1] http://ascape.sourceforge.net/manual/Section3.html >> [2] http://people.inf.elte.hu/legendi/

ATOM RSS1 RSS2