當前位置: 首頁>>代碼示例>>Java>>正文


Java GridFactory類代碼示例

本文整理匯總了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)
		);
}
 
開發者ID:dkremmydas,項目名稱:SugarScape2,代碼行數:16,代碼來源:Landscape.java

示例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);
}
 
開發者ID:eishub,項目名稱:BW4T,代碼行數:25,代碼來源:MapLoader.java

示例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;
	}
 
開發者ID:OpenSimulationSystems,項目名稱:CABSF_Java,代碼行數:49,代碼來源:JZombiesBuilder.java


注:本文中的repast.simphony.context.space.grid.GridFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。