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

The following examples show how to use burlap.mdp.core.oo.state.OOState#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: GoldBlockTF.java    From burlapcraft with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean isTerminal(State s) {
	OOState os = (OOState)s;

	BCAgent a = (BCAgent)os.object(CLASS_AGENT);

	HelperGeometry.Pose agentPose = HelperGeometry.Pose.fromXyz(a.x, a.y, a.z);

	HelperGeometry.Pose goalPose = getGoalPose(s);

	//are they at goal location or dead
	double distance = goalPose.distance(agentPose);
	//System.out.println("Distance: " + distance + " goal at: " + goalPose);

	if (distance < 0.5) {
		return true;
	} else {
		return false;
	}
}
 
Example 2
Source File: LunarLanderDomain.java    From burlap with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {
	
	
	LLAgent agent = (LLAgent)st.object(params[0]);
	LLBlock o = (LLBlock)st.object(params[1]);
	double x = agent.x;
	double y = agent.y;

	double l = o.left;
	double r = o.right;
	double b = o.bottom;
	double t = o.top;
	
	if(x >= l && x <= r && y >= b && y <= t){
		return true;
	}
	
	return false;
}
 
Example 3
Source File: LunarLanderDomain.java    From burlap with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {

	LLAgent agent = (LLAgent)st.object(params[0]);
	LLBlock.LLPad pad = (LLBlock.LLPad)st.object(params[1]);
	
	
	double l = pad.left;
	double r = pad.right;
	double b = pad.bottom;
	double t = pad.top;
	
	double x = agent.x;
	double y = agent.y;
	
	//on pad means landed on surface, so y should be equal to top
	if(x >= l && x < r && y >= b && y <= t){
		return true;
	}
	

	return false;
}
 
Example 4
Source File: CommandReachable.java    From burlapcraft with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {

	MinecraftDomainGenerator mdg = new MinecraftDomainGenerator();
	SADomain domain = mdg.generateDomain();

	State in = MinecraftStateGeneratorHelper.getCurrentState(BurlapCraft.currentDungeon);
	List<State> reachable = StateReachability.getReachableStates(in, domain, new SimpleHashableStateFactory());
	for(State s : reachable){
		OOState os = (OOState)s;
		BCAgent a = (BCAgent)os.object(CLASS_AGENT);
		System.out.println(a.x + ", " + a.y + ", " + a.z + ", " + a.rdir + ", "+ a.vdir + ", " + a.selected);
	}
	System.out.println(reachable.size());

}
 
Example 5
Source File: GridWorldDomain.java    From burlap with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {
	
	ObjectInstance agent = st.object(params[0]);
	ObjectInstance location = st.object(params[1]);
	
	int ax = (Integer)agent.get("x");
	int ay = (Integer)agent.get("y");
	
	int lx = (Integer)location.get("x");
	int ly = (Integer)location.get("y");
	
	if(ax == lx && ay == ly){
		return true;
	}
	
	return false;
}
 
Example 6
Source File: GridWorldDomain.java    From burlap with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {
	
	ObjectInstance agent = st.object(params[0]);
	
	int ax = (Integer)agent.get("x");
	int ay = (Integer)agent.get("y");
	
	int cx = ax + xdelta;
	int cy = ay + ydelta;
	
	if(cx < 0 || cx >= GridWorldDomain.this.width || cy < 0 || cy >= GridWorldDomain.this.height || GridWorldDomain.this.map[cx][cy] == 1 || 
			(xdelta > 0 && (GridWorldDomain.this.map[ax][ay] == 3 || GridWorldDomain.this.map[ax][ay] == 4)) || (xdelta < 0 && (GridWorldDomain.this.map[cx][cy] == 3 || GridWorldDomain.this.map[cx][cy] == 4)) ||
			(ydelta > 0 && (GridWorldDomain.this.map[ax][ay] == 2 || GridWorldDomain.this.map[ax][ay] == 4)) || (ydelta < 0 && (GridWorldDomain.this.map[cx][cy] == 2 || GridWorldDomain.this.map[cx][cy] == 4)) ){
		return true;
	}
	
	return false;
}
 
Example 7
Source File: FrostbiteDomain.java    From burlap with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {

	FrostbiteAgent agent = (FrostbiteAgent)st.object(params[0]);
	FrostbitePlatform platform = (FrostbitePlatform)st.object(params[1]);

	int x = platform.x;
	int y = platform.y;
	int s = platform.size;

	int ax = agent.x + agentSize / 2;
	int ay = agent.y + agentSize / 2;
	int ah = agent.height;

	if(ah != 0){
		return false;
	}

	return pointInPlatform(ax, ay, x, y, s);
}
 
Example 8
Source File: FrostbiteDomain.java    From burlap with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {
	FrostbiteIgloo igloo = (FrostbiteIgloo)st.object(params[0]);

	int building = igloo.height;
	return building >= 16;
}
 
Example 9
Source File: LunarLanderDomain.java    From burlap with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {

	LLAgent agent = (LLAgent)st.object(params[0]);
	double y = agent.y;
	
	if(y == ymin){
		return true;
	}
	
	return false;
}
 
Example 10
Source File: BlockDude.java    From burlap with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {

	BlockDudeAgent a = (BlockDudeAgent)st.object(params[0]);
	BlockDudeCell e = (BlockDudeCell)st.object(params[1]);

	if(a.x == e.x && a.y == e.y){
		return true;
	}

	return false;
}
 
Example 11
Source File: IRLExample.java    From burlap_examples with MIT License 5 votes vote down vote up
protected int getActiveLocationVal(OOState s){

			List<GroundedProp> gps = this.inLocationPF.allGroundings(s);
			for(GroundedProp gp : gps){
				if(gp.isTrue(s)){
					GridLocation l = (GridLocation)s.object(gp.params[1]);
					return l.type;
				}
			}

			return -1;
		}
 
Example 12
Source File: FrostbiteDomain.java    From burlap with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {
	FrostbiteAgent agent = (FrostbiteAgent)st.object(params[0]);

	int ay = agent.x + agentSize / 2;
	return ay < gameIceHeight;
}
 
Example 13
Source File: IDMaskedHashableState.java    From burlap with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean ooStatesEqual(OOState s1, OOState s2) {
	if (s1 == s2) {
		return true;
	}

	for(Map.Entry<String, List<ObjectInstance>> e1 : OOStateUtilities.objectsByClass(s1).entrySet()){

		String oclass = e1.getKey();

		if(config.maskedObjectClasses.contains(oclass)){
			continue;
		}

		List<ObjectInstance> objects = e1.getValue();

		List<ObjectInstance> oobjects = s2.objectsOfClass(oclass);
		if(objects.size() != oobjects.size()){
			return false;
		}

		for(ObjectInstance o : objects){
			ObjectInstance oo = s2.object(o.name());
			if(oo == null || !flatStatesEqual(o, oo)){
				return false;
			}
		}

	}

	return true;
}
 
Example 14
Source File: PFAgentOnBlock.java    From burlapcraft with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean isTrue(OOState s, String... params) {
	BCAgent a = (BCAgent)s.object(params[0]);
	BCBlock b = (BCBlock)s.object(params[1]);

	if ((a.x == b.x) && ((b.y + 1) == a.y) && a.z == b.z) {
		return true;
	}
	
	return false;
}
 
Example 15
Source File: ExampleOOGridWorld.java    From burlap_examples with MIT License 5 votes vote down vote up
@Override
public boolean isTrue(OOState s, String... params) {
	ObjectInstance agent = s.object(params[0]);
	ObjectInstance location = s.object(params[1]);

	int ax = (Integer)agent.get(VAR_X);
	int ay = (Integer)agent.get(VAR_Y);

	int lx = (Integer)location.get(VAR_X);
	int ly = (Integer)location.get(VAR_Y);

	return ax == lx && ay == ly;

}
 
Example 16
Source File: FrostbiteDomain.java    From burlap with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {
	FrostbitePlatform platform = (FrostbitePlatform)st.object(params[0]);
	return platform.activated;
}
 
Example 17
Source File: BlockDude.java    From burlap with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {

	BlockDudeAgent a = (BlockDudeAgent)st.object(params[0]);

	if(!a.holding){
		return false;
	}

	BlockDudeCell b = (BlockDudeCell)st.object(params[1]);


	if(a.x == b.x && a.y == b.y-1){
		return true;
	}

	return false;
}
 
Example 18
Source File: LunarLanderDomain.java    From burlap with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isTrue(OOState st, String... params) {

	LLAgent agent = (LLAgent)st.object(params[0]);
	LLBlock.LLPad pad = (LLBlock.LLPad)st.object(params[1]);


	double l = pad.left;
	double r = pad.right;
	double t = pad.top;

	double x = agent.x;
	double y = agent.y;
	
	//on pad means landed on surface, so y should be equal to top
	if(x > l && x < r && y == t){
		return true;
	}
	

	return false;
}
 
Example 19
Source File: PFBlockIsShape.java    From burlapcraft with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean isTrue(OOState s, String... params) {
	BCBlock block = (BCBlock)s.object(params[0]);
	return HelperActions.blockShapeMap.get(block.type).equals(this.shape);
}
 
Example 20
Source File: PFBlockIsType.java    From burlapcraft with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean isTrue(OOState s, String... params) {
	BCBlock block = (BCBlock)s.object(params[0]);
	return block.type == this.type;
}