mirror of
https://github.com/RAIRLab/Spectra.git
synced 2024-11-21 08:26:30 -05:00
Handling edge cases in precondition -> formula
This commit is contained in:
parent
492e7bac14
commit
a747b38233
2 changed files with 11 additions and 1 deletions
|
@ -49,7 +49,14 @@ public class Action {
|
|||
|
||||
this.freeVariables = freeVariables;
|
||||
|
||||
if (preconditions.size() > 1) {
|
||||
this.precondition = new And(preconditions.stream().collect(Collectors.toList()));
|
||||
} else if (preconditions.size() == 1) {
|
||||
this.precondition = preconditions.iterator().next();
|
||||
} else {
|
||||
this.precondition = State.TRUE;
|
||||
}
|
||||
|
||||
|
||||
this.weight = preconditions.stream().mapToInt(Formula::getWeight).sum() +
|
||||
additions.stream().mapToInt(Formula::getWeight).sum() +
|
||||
|
|
|
@ -12,14 +12,17 @@ import java.util.Set;
|
|||
public class State {
|
||||
|
||||
final Set<Formula> formulae;
|
||||
static Formula TRUE;
|
||||
static Formula FALSE;
|
||||
|
||||
static{
|
||||
|
||||
try {
|
||||
TRUE = Reader.readFormulaFromString("(or P (not P))");
|
||||
FALSE = Reader.readFormulaFromString("(and P (not P))");
|
||||
} catch (Reader.ParsingException e) {
|
||||
e.printStackTrace();
|
||||
TRUE = null;
|
||||
FALSE = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue