-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 413 operator transition (#680)
* Began updating case rule evaluation algorithm Added new logic to checkRuleRaw in CaseRule_Generic Updated null definition in CaseRule_GenericStatement Updated STT case rule constants * Fixed immutable cell bug Fixed bug in CaseRule_GenericStatement where cells that had type UNKNOWN in a generated case-rule board were immutable; Continued debugging for CaseRule_Generic; Updated specs and method descriptors. * Finalized rule verification Added final rule verification to CaseRule_Generic; Removed debugging. --------- Co-authored-by: Charles Tian <[email protected]>
- Loading branch information
1 parent
91366b0
commit fffa63b
Showing
7 changed files
with
316 additions
and
346 deletions.
There are no files selected for viewing
118 changes: 57 additions & 61 deletions
118
src/main/java/edu/rpi/legup/puzzle/shorttruthtable/ShortTruthTableOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,57 @@ | ||
package edu.rpi.legup.puzzle.shorttruthtable; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
public class ShortTruthTableOperation { | ||
|
||
public static final char AND = '^'; | ||
public static final char OR = '|'; | ||
public static final char NOT = '~'; | ||
public static final char CONDITIONAL = '>'; | ||
public static final char BICONDITIONAL = '-'; | ||
|
||
private ShortTruthTableOperation() { | ||
} | ||
|
||
|
||
public static String getLogicSymbol(char c) { | ||
switch (c) { | ||
case AND: | ||
return "\u2227"; | ||
case OR: | ||
return "\u2228"; | ||
case NOT: | ||
return "\u00AC"; | ||
case CONDITIONAL: | ||
return "\u2192"; | ||
case BICONDITIONAL: | ||
return "\u2194"; | ||
} | ||
return "" + c; | ||
} | ||
|
||
public static String getRuleName(char operation) { | ||
switch (operation) { | ||
case AND: | ||
return "And"; | ||
case OR: | ||
return "Or"; | ||
case NOT: | ||
return "Not"; | ||
case CONDITIONAL: | ||
return "Conditional"; | ||
case BICONDITIONAL: | ||
return "Biconditional"; | ||
} | ||
return null; | ||
} | ||
|
||
|
||
public static boolean isOperation(char c) { | ||
return c == AND || | ||
c == OR || | ||
c == NOT || | ||
c == CONDITIONAL || | ||
c == BICONDITIONAL; | ||
} | ||
|
||
|
||
} | ||
package edu.rpi.legup.puzzle.shorttruthtable; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
public class ShortTruthTableOperation { | ||
|
||
public static final char AND = '^'; | ||
public static final char OR = '|'; | ||
public static final char NOT = '~'; | ||
public static final char CONDITIONAL = '>'; | ||
public static final char BICONDITIONAL = '-'; | ||
|
||
private ShortTruthTableOperation() { | ||
} | ||
|
||
public static String getLogicSymbol(char c) { | ||
switch (c) { | ||
case AND: | ||
return "\u2227"; | ||
case OR: | ||
return "\u2228"; | ||
case NOT: | ||
return "\u00AC"; | ||
case CONDITIONAL: | ||
return "\u2192"; | ||
case BICONDITIONAL: | ||
return "\u2194"; | ||
} | ||
return "" + c; | ||
} | ||
|
||
public static String getRuleName(char operation) { | ||
switch (operation) { | ||
case AND: | ||
return "And"; | ||
case OR: | ||
return "Or"; | ||
case NOT: | ||
return "Not"; | ||
case CONDITIONAL: | ||
return "Conditional"; | ||
case BICONDITIONAL: | ||
return "Biconditional"; | ||
} | ||
return null; | ||
} | ||
|
||
public static boolean isOperation(char c) { | ||
return c == AND || | ||
c == OR || | ||
c == NOT || | ||
c == CONDITIONAL || | ||
c == BICONDITIONAL; | ||
} | ||
} |
46 changes: 23 additions & 23 deletions
46
src/main/java/edu/rpi/legup/puzzle/shorttruthtable/rules/caserule/CaseRuleAnd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
package edu.rpi.legup.puzzle.shorttruthtable.rules.caserule; | ||
|
||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableOperation; | ||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType; | ||
|
||
public class CaseRuleAnd extends CaseRule_GenericStatement { | ||
|
||
public CaseRuleAnd() { | ||
super("STTT-CASE-0001", ShortTruthTableOperation.AND, | ||
"And", | ||
trueCases, | ||
falseCases); | ||
} | ||
|
||
private static final ShortTruthTableCellType[][] trueCases = { | ||
{T, T} | ||
}; | ||
private static final ShortTruthTableCellType[][] falseCases = { | ||
{F, N}, | ||
{N, F} | ||
}; | ||
|
||
} | ||
package edu.rpi.legup.puzzle.shorttruthtable.rules.caserule; | ||
|
||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableOperation; | ||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType; | ||
|
||
public class CaseRuleAnd extends CaseRule_GenericStatement { | ||
|
||
public CaseRuleAnd() { | ||
super("STTT-CASE-0001", ShortTruthTableOperation.AND, | ||
"And", | ||
trueCases, | ||
falseCases); | ||
} | ||
|
||
private static final ShortTruthTableCellType[][] trueCases = { | ||
{T, T} | ||
}; | ||
private static final ShortTruthTableCellType[][] falseCases = { | ||
{F, U}, | ||
{U, F} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 23 additions & 23 deletions
46
src/main/java/edu/rpi/legup/puzzle/shorttruthtable/rules/caserule/CaseRuleConditional.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
package edu.rpi.legup.puzzle.shorttruthtable.rules.caserule; | ||
|
||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableOperation; | ||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType; | ||
|
||
public class CaseRuleConditional extends CaseRule_GenericStatement { | ||
|
||
public CaseRuleConditional() { | ||
super("STTT-CASE-0004", ShortTruthTableOperation.CONDITIONAL, | ||
"Conditional", | ||
trueCases, | ||
falseCases); | ||
} | ||
|
||
private static final ShortTruthTableCellType[][] trueCases = { | ||
{N, T}, | ||
{F, N} | ||
}; | ||
private static final ShortTruthTableCellType[][] falseCases = { | ||
{T, F}, | ||
}; | ||
|
||
} | ||
package edu.rpi.legup.puzzle.shorttruthtable.rules.caserule; | ||
|
||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableOperation; | ||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType; | ||
|
||
public class CaseRuleConditional extends CaseRule_GenericStatement { | ||
|
||
public CaseRuleConditional() { | ||
super("STTT-CASE-0004", ShortTruthTableOperation.CONDITIONAL, | ||
"Conditional", | ||
trueCases, | ||
falseCases); | ||
} | ||
|
||
private static final ShortTruthTableCellType[][] trueCases = { | ||
{U, T}, | ||
{F, U} | ||
}; | ||
private static final ShortTruthTableCellType[][] falseCases = { | ||
{T, F}, | ||
}; | ||
|
||
} |
46 changes: 23 additions & 23 deletions
46
src/main/java/edu/rpi/legup/puzzle/shorttruthtable/rules/caserule/CaseRuleOr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
package edu.rpi.legup.puzzle.shorttruthtable.rules.caserule; | ||
|
||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableOperation; | ||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType; | ||
|
||
public class CaseRuleOr extends CaseRule_GenericStatement { | ||
|
||
public CaseRuleOr() { | ||
super("STTT-CASE-0005", ShortTruthTableOperation.OR, | ||
"Or", | ||
trueCases, | ||
falseCases); | ||
} | ||
|
||
private static final ShortTruthTableCellType[][] trueCases = { | ||
{T, N}, | ||
{N, T} | ||
}; | ||
private static final ShortTruthTableCellType[][] falseCases = { | ||
{F, F}, | ||
}; | ||
|
||
} | ||
package edu.rpi.legup.puzzle.shorttruthtable.rules.caserule; | ||
|
||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableOperation; | ||
import edu.rpi.legup.puzzle.shorttruthtable.ShortTruthTableCellType; | ||
|
||
public class CaseRuleOr extends CaseRule_GenericStatement { | ||
|
||
public CaseRuleOr() { | ||
super("STTT-CASE-0005", ShortTruthTableOperation.OR, | ||
"Or", | ||
trueCases, | ||
falseCases); | ||
} | ||
|
||
private static final ShortTruthTableCellType[][] trueCases = { | ||
{T, U}, | ||
{U, T} | ||
}; | ||
private static final ShortTruthTableCellType[][] falseCases = { | ||
{F, F}, | ||
}; | ||
|
||
} |
Oops, something went wrong.