本文整理匯總了Java中repast.simphony.context.space.grid.GridFactory類的典型用法代碼示例。如果您正苦於以下問題:Java GridFactory類的具體用法?Java GridFactory怎麽用?Java GridFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GridFactory類屬於repast.simphony.context.space.grid包,在下文中一共展示了GridFactory類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import repast.simphony.context.space.grid.GridFactory; //導入依賴的package包/類
/**
* Initialize any values from here
*
* @param x the width of the landscape grid
* @param y the height of the landscape grid
*/
public void init(int x, int y) {
this.x = x;
this.y = y;
GridFactory gf = GridFactoryFinder.createGridFactory(null);
grid = (DefaultGrid<Agent>) gf.createGrid("sugarscapeGrid",
SimulationContext.getInstance(),
new GridBuilderParameters <Agent> (new WrapAroundBorders (),new RandomGridAdder<Agent>(),true , x, y)
);
}
示例2: createGridSpace
import repast.simphony.context.space.grid.GridFactory; //導入依賴的package包/類
/**
* Creates the {@link Grid} in which all objects will be placed, in conjuction with the continuous space. The grid
* space allows for querying for Von Neumann and Moore neighborhoods.
*
* @param context
* the context in which this space operates.
* @param mapWidth
* The width of the space
* @param mapHeight
* The height of the space
* @return the create grid for the given context and map dimensions
*/
private static Grid<Object> createGridSpace(BW4TServerMap smap) {
Context<Object> context = smap.getContext();
final Point area = smap.getMap().getArea();
int width = (int) area.getX() + 1;
int height = (int) area.getY() + 1;
GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
GridBuilderParameters<Object> params = new GridBuilderParameters<>(new StrictBorders(), new SimpleGridAdder<Object>(),
true, width, height);
return gridFactory.createGrid(GRID_PROJECTION_ID, context, params);
}
示例3: build
import repast.simphony.context.space.grid.GridFactory; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
//@Override
public Context build(Context<Object> context) {
double MAX_ITERATIONS = 300;
RunEnvironment runEnvironment = RunEnvironment.getInstance();
runEnvironment.endAt(MAX_ITERATIONS);
context.setId("jzombies");
NetworkBuilder<Object> netBuilder = new NetworkBuilder<Object>(
"infection network", context, true);
netBuilder.buildNetwork();
ContinuousSpaceFactory spaceFactory = ContinuousSpaceFactoryFinder
.createContinuousSpaceFactory(null);
ContinuousSpace<Object> space = spaceFactory.createContinuousSpace(
"space", context, new RandomCartesianAdder<Object>(),
new repast.simphony.space.continuous.WrapAroundBorders(), 50,
50);
GridFactory gridFactory = GridFactoryFinder.createGridFactory(null);
Grid<Object> grid = gridFactory.createGrid("grid", context,
new GridBuilderParameters<Object>(new WrapAroundBorders(),
new SimpleGridAdder<Object>(), true, 50, 50));
Parameters params = RunEnvironment.getInstance().getParameters();
int zombieCount = (Integer) params.getValue("zombie_count");
for (int i = 0; i < zombieCount; i++) {
context.add(new Zombie(space, grid));
}
int humanCount = (Integer) params.getValue("human_count");
for (int i = 0; i < humanCount; i++) {
int energy = RandomHelper.nextIntFromTo(4, 10);
context.add(new Human(space, grid, energy));
}
for (Object obj : context) {
NdPoint pt = space.getLocation(obj);
grid.moveTo(obj, (int) pt.getX(), (int) pt.getY());
}
/* if (RunEnvironment.getInstance().isBatch()) {
RunEnvironment.getInstance().endAt(20);
}*/
return context;
}