Skip to content

Commit

Permalink
Issue 413 operator transition (#680)
Browse files Browse the repository at this point in the history
* 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
Chase-Grajeda and charlestian23 authored Nov 7, 2023
1 parent 91366b0 commit fffa63b
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 346 deletions.
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;
}
}
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}
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public CaseRuleAtomic() {
super("STTT-CASE-0002", "Atomic",
"True or False",
"Each unknown cell must either be true or false");
System.out.println("Case Rule T/F constructor");
}

// Adds all elements that can be selected for this case rule
Expand Down
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},
};

}
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},
};

}
Loading

0 comments on commit fffa63b

Please sign in to comment.