Java Code Examples for burlap.mdp.core.oo.propositional.GroundedProp#isTrue()

The following examples show how to use burlap.mdp.core.oo.propositional.GroundedProp#isTrue() . 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: GameSequenceVisualizer.java    From burlap with Apache License 2.0 6 votes vote down vote up
private void updatePropTextArea(State s){

		if(!(domain instanceof OODomain) || !(s instanceof OOState)){
			return ;
		}

	    StringBuilder buf = new StringBuilder();
		
		List <PropositionalFunction> props = ((OODomain)domain).propFunctions();
		for(PropositionalFunction pf : props){
			List<GroundedProp> gps = pf.allGroundings((OOState)s);
			for(GroundedProp gp : gps){
				if(gp.isTrue((OOState)s)){
					buf.append(gp.toString()).append("\n");
				}
			}
		}
		
		propViewer.setText(buf.toString());
		
		
		
	}
 
Example 2
Source File: PFFeatures.java    From burlap with Apache License 2.0 6 votes vote down vote up
@Override
public double[] features(State s) {
	
	List<Double> featureValueList = new LinkedList<Double>();
	for(PropositionalFunction pf : this.pfsToUse){
		//List<GroundedProp> gps = s.getAllGroundedPropsFor(pf);
		List<GroundedProp> gps = pf.allGroundings((OOState)s);
		for(GroundedProp gp : gps){
			if(gp.isTrue((OOState)s)){
				featureValueList.add(1.);
			}
			else{
				featureValueList.add(0.);
			}
		}
	}
	
	double [] fv = new double[featureValueList.size()];
	int i = 0;
	for(double f : featureValueList){
		fv[i] = f;
		i++;
	}
	
	return fv;
}
 
Example 3
Source File: EpisodeSequenceVisualizer.java    From burlap with Apache License 2.0 6 votes vote down vote up
protected void updatePropTextArea(State s){

		if(!(domain instanceof OODomain) || !(s instanceof OOState)){
			return ;
		}

	    StringBuilder buf = new StringBuilder();
		
		List <PropositionalFunction> props = ((OODomain)domain).propFunctions();
		for(PropositionalFunction pf : props){
			//List<GroundedProp> gps = s.getAllGroundedPropsFor(pf);
			List<GroundedProp> gps = pf.allGroundings((OOState)s);
			for(GroundedProp gp : gps){
				if(gp.isTrue((OOState)s)){
					buf.append(gp.toString()).append("\n");
				}
			}
		}
		
		propViewer.setText(buf.toString());
		
		
		
	}
 
Example 4
Source File: VisualWorldObserver.java    From burlap with Apache License 2.0 6 votes vote down vote up
private void updatePropTextArea(State s){

		if(!(domain instanceof OODomain) || !(s instanceof OOState)){
			return ;
		}

	    StringBuilder buf = new StringBuilder();
		
		List <PropositionalFunction> props = ((OODomain)domain).propFunctions();
		for(PropositionalFunction pf : props){
			//List<GroundedProp> gps = s.getAllGroundedPropsFor(pf);
			List<GroundedProp> gps = pf.allGroundings((OOState)s);
			for(GroundedProp gp : gps){
				if(gp.isTrue((OOState)s)){
					buf.append(gp.toString()).append("\n");
				}
			}
		}
		propViewer.setText(buf.toString());
		
		
	}
 
Example 5
Source File: VisualActionObserver.java    From burlap with Apache License 2.0 6 votes vote down vote up
private void updatePropTextArea(State s){

		if(domain == null || !(s instanceof OOState)){
			return ;
		}

	    StringBuilder buf = new StringBuilder();
		
		List <PropositionalFunction> props = ((OODomain)domain).propFunctions();
		for(PropositionalFunction pf : props){
			List<GroundedProp> gps = pf.allGroundings((OOState)s);
			for(GroundedProp gp : gps){
				if(gp.isTrue((OOState)s)){
					buf.append(gp.toString()).append("\n");
				}
			}
		}
		propViewer.setText(buf.toString());
		
		
	}
 
Example 6
Source File: VisualExplorer.java    From burlap with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the propositional function evaluation text display for the given state.
 * @param s the input state on which propositional functions are to be evaluated.
 */
protected void updatePropTextArea(State s){

	if(!(domain instanceof OODomain) || !(s instanceof OOState)){
		return ;
	}

    StringBuilder buf = new StringBuilder();
	
	List <PropositionalFunction> props = ((OODomain)domain).propFunctions();
	for(PropositionalFunction pf : props){
		List<GroundedProp> gps = pf.allGroundings((OOState)s);
		for(GroundedProp gp : gps){
			if(gp.isTrue((OOState)s)){
				buf.append(gp.toString()).append("\n");
			}
		}
	}
	propViewer.setText(buf.toString());
	
	
}
 
Example 7
Source File: SGVisualExplorer.java    From burlap with Apache License 2.0 6 votes vote down vote up
protected void updatePropTextArea(State s){

		if(!(domain instanceof OODomain) || !(s instanceof OOState)){
			return;
		}

	    StringBuilder buf = new StringBuilder();
		
		List <PropositionalFunction> props = ((OODomain)domain).propFunctions();
		for(PropositionalFunction pf : props){
			List<GroundedProp> gps = pf.allGroundings((OOState)s);
			for(GroundedProp gp : gps){
				if(gp.isTrue((OOState)s)){
					buf.append(gp.toString()).append("\n");
				}
			}
		}
		

		propViewer.setText(buf.toString());
		
		
	}
 
Example 8
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 9
Source File: CommandCheckProps.java    From burlapcraft with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {

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

	boolean printFalse = false;
	if(args.length > 0){
		if(args[0].equals("+not")){
			printFalse = true;
		}
	}

	State s = MinecraftStateGeneratorHelper.getCurrentState(BurlapCraft.currentDungeon);

	List<GroundedProp> gps = PropositionalFunction.allGroundingsFromList(domain.propFunctions(), (OOState)s);
	StringBuffer buf = new StringBuffer();
	buf.append("\n");
	for(GroundedProp gp : gps){
		if(!gp.isTrue((OOState)s)){
			if(printFalse) {
				buf.append("NOT ");
				buf.append(gp.toString());
				buf.append("\n");
			}
		}
		else{
			buf.append(gp.toString());
			buf.append("\n");
		}

	}
	


	sender.addChatMessage(new ChatComponentText(buf.toString()));

}
 
Example 10
Source File: SinglePFSCT.java    From burlap with Apache License 2.0 5 votes vote down vote up
@Override
public boolean satisfies(State s) {
	
	//List<GroundedProp> gps = s.getAllGroundedPropsFor(pf);
	List<GroundedProp> gps = this.pf.allGroundings((OOState)s);
	
	for(GroundedProp gp : gps){
		if(gp.isTrue((OOState)s)){
			return true;
		}
	}
	
	return false;
	
}
 
Example 11
Source File: ListPropFunctions.java    From burlap with Apache License 2.0 4 votes vote down vote up
@Override
public int call(BurlapShell shell, String argString, Scanner is, PrintStream os) {
	Environment env = ((EnvironmentShell)shell).getEnv();

	OptionSet oset = this.parser.parse(argString.split(" "));

	if(oset.has("h")){
		os.println("[s]\nCommand to list all true (or false) grounded propositional function for the current environment observation.\n" +
				"-f: list false grounded propositional functions, rather than true ones. " +
				"-n: list the name of all propositional functions, rather than grounded evaluations\n" +
				"-s: evaluate propositional functions on POMDP environment hidden state, rather than environment observation. Environment must extend SimulatedPOEnvironment");

		return 0;
	}


	if(!(shell.getDomain() instanceof OODomain)){
		os.println("cannot query propositional functions because the domain is not an OODomain");
		return 0;
	}

	if(oset.has("n")){
		for(PropositionalFunction pf : ((OODomain)shell.getDomain()).propFunctions()){
			os.println(pf.getName());
		}
		return 0;
	}


	State qs = env.currentObservation();

	if(oset.has("s")){
		if(!(env instanceof SimulatedPOEnvironment)){
			os.println("Cannot query applicable actions with respect to POMDP hidden state, because the environment does not extend SimulatedPOEnvironment.");
			return 0;
		}
		qs = ((SimulatedPOEnvironment)env).getCurrentHiddenState();
	}

	List<GroundedProp> gps = PropositionalFunction.allGroundingsFromList(((OODomain)shell.getDomain()).propFunctions(), (OOState)qs);
	for(GroundedProp gp : gps){
		if(gp.isTrue((OOState)qs) == !oset.has("f")){
			os.println(gp.toString());
		}
	}

	return 0;
}