I'm trying to position agents randomly into a GeomVectorField in MASON by setting the random coordinates. The swarm example with a continuous2D field is as follows:
agents.setObjectLocation(agent,
new Double2D(random.nextDouble()*width, random.nextDouble() * height));
I think to get random coordinate from a GeomVectorField the code should look like:
double xcoord = random.nextDouble() * world.censusTracts.getWidth();
double ycoord = random.nextDouble() * world.censusTracts.getWidth();
And, this is my grid field in class world:
public GeomVectorField censusTracts = new GeomVectorField();
However, MASON does not recognize the random. Am I missing a library? I've included the following libraries:
import sim.field.geo.GeomVectorField;
import sim.field.grid.*;
import sim.util.*;
How can I pull a random coordinate from a GeomVectorField?
Thanks,
Annetta
|