Class State

java.lang.Object
  |
  +--MathSet
        |
        +--State

public class State
extends MathSet

This class implements a state, i.e. a set of fluents. Fluents that belong to the set are considered to be true in the state. Fluents that do not belong to the set are considered to be false.


Constructor Summary
State(Vector f)
          Constructs a state based on the given set of fluents.
State(Vector f, boolean defTruth)
          Constructs a state based on the given set of fluents.
 
Method Summary
 boolean isTrue(int index)
          Checks if the given fluent is true in the state.
 boolean isTrue(String fluent)
          Checks if the given fluent is true in the state.
 void set(int index, boolean truth)
          Sets a fluent's truth value.
 void set(String fluent, boolean truth)
          Sets a fluent's truth value.
 String toString()
          Returns a string representation of the state.
 String toStringAsSet()
          Returns a string representation of the state in form of a set.
 Vector toVector()
          Returns a Vector representing this set.
 
Methods inherited from class MathSet
add, diff, diff, get, intersect, intersect, list, remove, size, union, union
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

State

public State(Vector f,
             boolean defTruth)
Constructs a state based on the given set of fluents. All fluents are assigned the specified default truth value.
Parameters:
f - the set of fluents used to build this state
defTruth - the default value for fluents

State

public State(Vector f)
Constructs a state based on the given set of fluents. All fluents are assumed to be false.
Parameters:
f - the set of fluents used to build this state
Method Detail

isTrue

public boolean isTrue(int index)
Checks if the given fluent is true in the state.
Parameters:
index - the index of the fluent to be checked
Returns:
true if the fluent is true; false otherwise

isTrue

public boolean isTrue(String fluent)
Checks if the given fluent is true in the state.
Parameters:
fluent - the fluent to be checked
Returns:
true if the fluent is true; false otherwise

set

public void set(int index,
                boolean truth)
Sets a fluent's truth value.
Parameters:
index - the index of the fluent to be modified
truth - the truth value to be assigned to the fluent

set

public void set(String fluent,
                boolean truth)
Sets a fluent's truth value.
Parameters:
fluent - the fluent to be modified
truth - the truth value to be assigned to the fluent

toString

public String toString()
Returns a string representation of the state. Fluents are separated by a space. Fluents which are true are listed by their name. Fluents which are false have a "-" prefixed to their name.
Overrides:
toString in class MathSet
Returns:
the string representation of the state

toStringAsSet

public String toStringAsSet()
Returns a string representation of the state in form of a set. The beginning and the end of the state are marked by "{" and "}". Fluents are separated by a comma. Fluents which are true are listed by their name. Fluents which are false have a "-" prefixed to their name.
Returns:
the string representation of the state

toVector

public Vector toVector()
Returns a Vector representing this set. Each element of the Vector describes a different fluent, and consists of a string containing the name of the fluent, a number of spaces, and either "true" or "false", depending on the truth value of the fluent. The number of spaces in the string is computed so that the two columns are aligned for all the elements of the Vector.
Overrides:
toVector in class MathSet
Returns:
the Vector representing the state