Skip to content

Commit

Permalink
Merge pull request #826 from zachbonagura/binary
Browse files Browse the repository at this point in the history
Binary
  • Loading branch information
zacharybonagura authored Jun 18, 2024
2 parents 12add88 + 65db0f7 commit c3fb60d
Show file tree
Hide file tree
Showing 58 changed files with 432 additions and 362 deletions.
13 changes: 0 additions & 13 deletions src/main/java/edu/rpi/legup/model/Puzzle.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public abstract class Puzzle implements IBoardSubject, ITreeSubject {
protected List<ContradictionRule> contradictionRules;
protected List<CaseRule> caseRules;
protected List<PlaceableElement> placeableElements;
protected List<NonPlaceableElement> nonPlaceableElements;

/** Puzzle Constructor - creates a new Puzzle */
public Puzzle() {
Expand All @@ -65,7 +64,6 @@ public Puzzle() {
this.caseRules = new ArrayList<>();

this.placeableElements = new ArrayList<>();
this.nonPlaceableElements = new ArrayList<>();

registerRules();
registerPuzzleElements();
Expand Down Expand Up @@ -95,9 +93,6 @@ private void registerPuzzleElements() {
case PLACEABLE:
this.addPlaceableElement((PlaceableElement) element);
break;
case NONPLACEABLE:
this.addNonPlaceableElement((NonPlaceableElement) element);
break;
default:
break;
}
Expand Down Expand Up @@ -338,10 +333,6 @@ public List<PlaceableElement> getPlaceableElements() {
return placeableElements;
}

public List<NonPlaceableElement> getNonPlaceableElements() {
return nonPlaceableElements;
}

/**
* Sets the list of direct rules
*
Expand All @@ -364,10 +355,6 @@ public void addPlaceableElement(PlaceableElement element) {
placeableElements.add(element);
}

public void addNonPlaceableElement(NonPlaceableElement element) {
nonPlaceableElements.add(element);
}

/**
* Remove a basic rule from this Puzzle
*
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/edu/rpi/legup/model/elements/ElementType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.rpi.legup.model.elements;

public enum ElementType {
PLACEABLE,
NONPLACEABLE
PLACEABLE
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package edu.rpi.legup.model.elements;

public abstract class NonPlaceableElement extends Element {
public NonPlaceableElement(
String elementID, String elementName, String description, String imageName) {
super(elementID, elementName, description, imageName);
this.elementType = ElementType.NONPLACEABLE;
}
}
//package edu.rpi.legup.model.elements;
//
//public abstract class NonPlaceableElement extends Element {
// public NonPlaceableElement(
// String elementID, String elementName, String description, String imageName) {
// super(elementID, elementName, description, imageName);
// this.elementType = ElementType.PLACEABLE;
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class NumberTile extends PlaceableElement {
public NumberTile() {
super(
"BINA-PLAC-0001",
"BINA-ELEM-0001",
"Number Tile",
"A number tile",
"edu/rpi/legup/images/binary/tiles/NumberTile.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class UnknownTile extends PlaceableElement {
public UnknownTile() {
super(
"BINA-PLAC-0002",
"BINA-ELEM-0002",
"Unknown Tile",
"A blank tile",
"edu/rpi/legup/images/binary/tiles/UnknownTile.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BINA-PLAC-0001 : NumberTile
BINA-PLAC-0002 : UnknownTile
BINA-ELEM-0001 : NumberTile
BINA-ELEM-0002 : UnknownTile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,51 @@
import edu.rpi.legup.puzzle.binary.BinaryBoard;
import edu.rpi.legup.puzzle.binary.BinaryCell;

public class EliminateTheImpossible extends DirectRule {
import java.util.ArrayList;

public class EliminateTheImpossibleDirectRule extends DirectRule {
private final String INVALID_USE_MESSAGE = "Number at cell is incorrect";

public EliminateTheImpossible() {
public EliminateTheImpossibleDirectRule() {
super(
"BINA-BASC-0003",
"Eliminate The Impossible",
"If three adjacent empty cells are open, prevents a trio of numbers to exist",
"edu/rpi/legup/images/binary/rules/OneTileGapDirectRule.png");
}

// Function to generate all binary strings
static String generateAllBinaryStrings(int n, String arr, int i)
{
if (i == n)
{
return arr;
}

// First assign "0" at ith position
// and try for all other permutations
// for remaining positions
arr = arr + "0";
generateAllBinaryStrings(n, arr, i + 1);

// And then assign "1" at ith position
// and try for all other permutations
// for remaining positions
arr = arr + "1";
generateAllBinaryStrings(n, arr, i + 1);

return null;
}

public ArrayList<String> binaryCombiniations(int numEmpty) {

ArrayList<String> possibilities = new ArrayList<>();
String arr = "";
if (generateAllBinaryStrings(numEmpty, arr, 0) != null) {
possibilities.add(arr);
}
return null;
}
@Override
public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) {
BinaryBoard origBoard = (BinaryBoard) transition.getParents().get(0).getBoard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class BlackTile extends PlaceableElement {
public BlackTile() {
super(
"FPIX-PLAC-0001",
"FPIX-ELEM-0001",
"Black Tile",
"The black tile",
"edu/rpi/legup/images/fillapix/tiles/BlackTile.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package edu.rpi.legup.puzzle.fillapix.elements;

import edu.rpi.legup.model.elements.NonPlaceableElement;
import edu.rpi.legup.model.elements.PlaceableElement;

public class NumberTile extends NonPlaceableElement {
public class NumberTile extends PlaceableElement {
private int object_num;

public NumberTile() {
super(
"FPIX-UNPL-0001",
"FPIX-ELEM-0002",
"Number Tile",
"A numbered tile",
"edu/rpi/legup/images/fillapix/tiles/NumberTile.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package edu.rpi.legup.puzzle.fillapix.elements;

import edu.rpi.legup.model.elements.NonPlaceableElement;
import edu.rpi.legup.model.elements.PlaceableElement;

public class UnknownTile extends NonPlaceableElement {
public class UnknownTile extends PlaceableElement {
public UnknownTile() {
super(
"FPIX-UNPL-0002",
"FPIX-ELEM-0003",
"Unknown Tile",
"A blank tile",
"edu/rpi/legup/images/fillapix/tiles/UnknownTile.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class WhiteTile extends PlaceableElement {
public WhiteTile() {
super(
"FPIX-PLAC-0002",
"FPIX-ELEM-0004",
"White Tile",
"The white tile",
"edu/rpi/legup/images/fillapix/tiles/WhiteTile.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FPIX-PLAC-0001 : BlackTile
FPIX-PLAC-0002 : WhiteTile

FPIX-UNPL-0001 : NumberTile
FPIX-UNPL-0002 : UnknownTile
FPIX-ELEM-0001 : BlackTile
FPIX-ELEM-0002 : NumberTile
FPIX-ELEM-0003 : UnknownTile
FPIX-ELEM-0004 : WhiteTile
6 changes: 3 additions & 3 deletions src/main/java/edu/rpi/legup/puzzle/lightup/LightUpBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ public int getNumAdjLite(LightUpCell cell) {
}

/**
* Gets the number of adjacent cells that are placable
* Gets the number of adjacent cells that are placeable
*
* @param cell specified cell
* @return number of adjacent cells that are placable
* @return number of adjacent cells that are placeable
*/
public int getNumPlacble(LightUpCell cell) {
public int getNumPlaceable(LightUpCell cell) {
int num = 0;
Set<LightUpCell> adjCells = getAdj(cell);
for (LightUpCell c : adjCells) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package edu.rpi.legup.puzzle.lightup.elements;

import edu.rpi.legup.model.elements.NonPlaceableElement;
import edu.rpi.legup.model.elements.PlaceableElement;

public class BlackTile extends NonPlaceableElement {
public class BlackTile extends PlaceableElement {
public BlackTile() {
super(
"LTUP-UNPL-0002",
"LTUP-ELEM-0001",
"Black Tile",
"The black tile",
"edu/rpi/legup/images/lightup/black.gif");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class BulbTile extends PlaceableElement {
public BulbTile() {
super(
"LTUP-PLAC-0001",
"LTUP-ELEM-0002",
"Bulb Tile",
"The bulb tile",
"edu/rpi/legup/images/lightup/light.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package edu.rpi.legup.puzzle.lightup.elements;

import edu.rpi.legup.model.elements.NonPlaceableElement;
import edu.rpi.legup.model.elements.PlaceableElement;

public class NumberTile extends NonPlaceableElement {
public class NumberTile extends PlaceableElement {

int object_number;

// Follow the default format and resolves the NoSuchMethod error
public NumberTile() {
super(
"LTUP-UNPL-0001",
"LTUP-ELEM-0003",
"Number Tile",
"The number tile",
"edu/rpi/legup/images/lightup/1.gif");
}

public NumberTile(int num) {
super(
"LTUP-UNPL-0001",
"LTUP-ELEM-0003",
"Number Tile",
"The number tile",
"edu/rpi/legup/images/lightup/" + num + ".gif");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package edu.rpi.legup.puzzle.lightup.elements;

import edu.rpi.legup.model.elements.NonPlaceableElement;
import edu.rpi.legup.model.elements.PlaceableElement;

public class UnknownTile extends NonPlaceableElement {
public class UnknownTile extends PlaceableElement {
public UnknownTile() {
super(
"LTUP-UNPL-0003",
"LTUP-ELEM-0004",
"Unknown Tile",
"A blank tile",
"edu/rpi/legup/images/lightup/UnknownTile.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LTUP-ELEM-0001 : BlackTile
LTUP-ELEM-0002 : BulbTile
LTUP-ELEM-0003 : NumberTile
LTUP-ELEM-0004 : UnknownTile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public String checkContradictionAt(Board board, PuzzleElement puzzleElement) {
}

int bulbs = lightUpBoard.getNumAdj(cell, LightUpCellType.BULB);
int placeable = lightUpBoard.getNumPlacble(cell);
int placeable = lightUpBoard.getNumPlaceable(cell);

if (bulbs + placeable < cell.getData()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class BlackTile extends PlaceableElement {
public BlackTile() {
super(
"NURI-PLAC-0001",
"NURI-ELEM-0001",
"Black Tile",
"The black tile",
"edu/rpi/legup/images/nurikabe/tiles/BlackTile.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package edu.rpi.legup.puzzle.nurikabe.elements;

import edu.rpi.legup.model.elements.NonPlaceableElement;
import edu.rpi.legup.model.elements.PlaceableElement;

public class NumberTile extends NonPlaceableElement {
public class NumberTile extends PlaceableElement {
private int object_num;

public NumberTile() {
super(
"NURI-UNPL-0001",
"NURI-ELEM-0002",
"Number Tile",
"A numbered tile",
"edu/rpi/legup/images/nurikabe/tiles/NumberTile.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package edu.rpi.legup.puzzle.nurikabe.elements;

import edu.rpi.legup.model.elements.NonPlaceableElement;
import edu.rpi.legup.model.elements.PlaceableElement;

public class UnknownTile extends NonPlaceableElement {
public class UnknownTile extends PlaceableElement {
public UnknownTile() {
super(
"NURI-UNPL-0002",
"NURI-ELEM-0003",
"Unknown Tile",
"A blank tile",
"edu/rpi/legup/images/nurikabe/tiles/UnknownTile.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class WhiteTile extends PlaceableElement {
public WhiteTile() {
super(
"NURI-PLAC-0002",
"NURI-ELEM-0004",
"White Tile",
"The white tile",
"edu/rpi/legup/images/nurikabe/tiles/WhiteTile.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NURI-ELEM-0001 : BlackTile
NURI-ELEM-0002 : NumberTile
NURI-ELEM-0003 : UnknownTile
NURI-ELEM-0004 : WhiteTile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package edu.rpi.legup.puzzle.shorttruthtable.elements;

import edu.rpi.legup.model.elements.NonPlaceableElement;
import edu.rpi.legup.model.elements.PlaceableElement;

public class ArgumentElement extends NonPlaceableElement {
public class ArgumentElement extends PlaceableElement {
public ArgumentElement() {
super(
"STTT-UNPL-0001",
"STTT-ELEM-0001",
"Argument Element",
"Argument of logic statement element",
"edu/rpi/legup/images/shorttruthtable/tiles/LetterTile.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class GreenElement extends PlaceableElement {
public GreenElement() {
super(
"STTT-PLAC-0001",
"STTT-ELEM-0002",
"Green Element",
"A green tile to set certain tiles to true",
"edu/rpi/legup/images/shorttruthtable/tiles/GreenTile.png");
Expand Down
Loading

0 comments on commit c3fb60d

Please sign in to comment.