Java Code Examples for burlap.mdp.core.oo.state.generic.GenericOOState#object()

The following examples show how to use burlap.mdp.core.oo.state.generic.GenericOOState#object() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MinecraftModel.java    From burlapcraft with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void simMove(GenericOOState gs){

		//get agent and current position
		BCAgent agent = (BCAgent)gs.touch(CLASS_AGENT);


		//get objects and their positions
		List<ObjectInstance> blocks = gs.objectsOfClass(HelperNameSpace.CLASS_BLOCK);
		List<HelperPos> coords = new ArrayList<HelperPos>();
		for (ObjectInstance block : blocks) {
			int blockX = ((BCBlock)block).x;
			int blockY = ((BCBlock)block).y;
			int blockZ = ((BCBlock)block).z;
			coords.add(new HelperPos(blockX, blockY, blockZ));
		}

		//get resulting position
		int [][][] map = ((BCMap)gs.object(CLASS_MAP)).map;
		HelperPos newPos = this.moveResult(agent.x, agent.y, agent.z, agent.rdir, coords, map);

		//set the new position
		agent.x = newPos.x;
		agent.y = newPos.y;
		agent.z = newPos.z;

	}
 
Example 2
Source File: MinecraftModel.java    From burlapcraft with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void simDestroy(GenericOOState gs){

		//get agent and current position
		BCAgent agent = (BCAgent)gs.object(CLASS_AGENT);
		BCInventory inv = (BCInventory)gs.object(CLASS_INVENTORY);
		if(agent.selected < 0 || agent.selected > 8 || agent.vdir != 1){
			return;
		}

		int itemId = inv.inv[agent.selected].type;
		if(itemId != 278){
			return;
		}

		List<ObjectInstance> oblocks = gs.objectsOfClass(CLASS_BLOCK);

		List<BCBlock> blocks = new ArrayList<BCBlock>(oblocks.size());
		for(ObjectInstance ob : oblocks){
			blocks.add((BCBlock)ob);
		}

		this.destroyResult(agent.x, agent.y, agent.z, agent.rdir, blocks, gs);


	}
 
Example 3
Source File: MinecraftModel.java    From burlapcraft with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void simPlace(GenericOOState gs){

		BCAgent agent = (BCAgent)gs.object(CLASS_AGENT);

		if(agent.vdir != 1 || agent.selected < 0 || agent.selected > 8){
			return;
		}

		BCInventory inv = (BCInventory)gs.object(CLASS_INVENTORY);
		if(inv.inv[agent.selected].type == -1 || !HelperActions.blockIsOneOf(Block.getBlockById(inv.inv[agent.selected].type), mineableBlocks)){
			return;
		}

		List<ObjectInstance> oblocks = gs.objectsOfClass(CLASS_BLOCK);

		List<BCBlock> blocks = new ArrayList<BCBlock>(oblocks.size());
		for(ObjectInstance ob : oblocks){
			blocks.add((BCBlock)ob);
		}

		int [][][] map = ((BCMap)gs.object(CLASS_MAP)).map;

		placeResult(agent.x, agent.y, agent.z, agent.rdir, blocks, agent.selected, map, gs);

	}