Skip to content

Commit

Permalink
Bug fixes for the Thermometer Bug Fixes (#794)
Browse files Browse the repository at this point in the history
* Fixed Short Truth Table case rule bug (#707)

* Revert "Bugfix 549 (#682)"

This reverts commit 5048ee6.

* Case rule test fix (#705)

Co-authored-by: Chase Grajeda <[email protected]>

* Rapid fix for STT case rules

Case rules broke at some point from legacy code or merge conflict. Provided is a quick fix in CaseRule and CaseRule_Generic

* Revert "Revert "Bugfix 549 (#682)"" (#706)

This reverts commit e9fe310.

---------

Co-authored-by: Chase-Grajeda <[email protected]>
Co-authored-by: Chase Grajeda <[email protected]>

* Skyscrapers Test Suite (#708)

* Simplify rule names

* Contradiction Test Suite

* checkstyle

* Update Exporter

* Revert "Update Exporter"

This reverts commit bae1a1f.

* Case Rule Test Suite

* Update SkyscrapersExporter.java

* allow null transitions

* Update TreeTransition.java

* Direct Rule Test Suite

* added tests pass

* Update DirectRule.java

Commenting out print statement

---------

Co-authored-by: ThisMatt <[email protected]>
Co-authored-by: ThisMatt <[email protected]>
Co-authored-by: Chase Grajeda <[email protected]>

* Skyscrapers puzzle editor (#720)

* Fixed Short Truth Table case rule bug (#707)

* Revert "Bugfix 549 (#682)"

This reverts commit 5048ee6.

* Case rule test fix (#705)

Co-authored-by: Chase Grajeda <[email protected]>

* Rapid fix for STT case rules

Case rules broke at some point from legacy code or merge conflict. Provided is a quick fix in CaseRule and CaseRule_Generic

* Revert "Revert "Bugfix 549 (#682)"" (#706)

This reverts commit e9fe310.

---------

Co-authored-by: Chase-Grajeda <[email protected]>
Co-authored-by: Chase Grajeda <[email protected]>

* Implementing Puzzle Editor

Removing Extraneous TreeTent Code
Allowing setting tile number

* Allow for editing clues on all axies

* Remove Extraneous Code

Removed functionality required for TreeTent but unnecessary for Skyscrapers

* Remove Extraneous Code

* Clue Tile in Editor

Editor now requires selecting the clue tile to edit clues
Added images for the tiles

* Merge branch 'dev' into skyscrapersPuzzleEditor

* Checkstyle Requirement

* Necessary Code

* Allow for test functionality

---------

Co-authored-by: Charles Tian <[email protected]>
Co-authored-by: Chase-Grajeda <[email protected]>
Co-authored-by: Chase Grajeda <[email protected]>

* Starting work on thermometer class

* Added Vial Class

Added the vial class which will be helpful for checking rules down the line

* Discontinuous Mercury Rule added

Added the Discontinuous Mercury contradiciton rule. Added variables to the ThermometerBoard class to keep track of the numbers on the perimiter of the board as well as accessors/setters for these variables. Rewrote a section of the Vials code to make sure cells are added correctly as well as added some accessor functions.

* Java Autoformatter (#728)

* Create java-autoformat.yml

* Setup Java

* Run spotless on repository

* Adding spotless dependency during build

* Adding spotless dependency during build

* Give permissions to run spotless

* Syntax

* Adding Debug Tag

* Check for modified files

Also removed debug tag

* Automated Java code formatting changes

* Test command syntax

* Correctly Identify modified files

* Test autoformatter

* Test autoformatter

* Test autoformatter

* Debugging

* Debugging

* Change method for detecting changed files

* Try building before calling spotless

* Update java-autoformat.yml

* Update java-autoformat.yml

* Update java-autoformat.yml

* Purposely bad formatting

Purposely adding some bad formatting to see if the auto-formatter triggers

* Update build.gradle

Disabling Checkstyle in build so the auto-formatter can trigger

* Update java-autoformat.yml

Have auto-formatter trigger when more commits are added to a pull request

* Debugging

* Adding more awful formatting

* Update java-autoformat.yml

* Changing repo URL

* Going back to checkout v1

* Trying URL change

* Trying out using env

* Trying this now...?

* Introducing more horrible changes

* Spotless formatting using google format v1.19.2

* Manual formatting fix

* Automated Java code formatting changes

* Different format type

Trying to get it to pass checkstyle

* Disable checkstyle temporarily

* Automated Java code formatting changes

* Default google formatting style

* Automated Java code formatting changes

* Comments and reordering styles

* Adding extra newlines

* Automated Java code formatting changes

* Changing tabs from 2 to 4 spaces

Supposedly the only difference that aosp makes is the 2 spaces?
Hopefully it doesn't break anything else

* Remove solo } requirement and reactivate checkstyle

* Automated Java code formatting changes

* Update checkstyle.xml

Removed problematic LeftCurly and RightCurly requirements

* Changing back to tabWidth

* Add newline to test formatter + build

* Automated Java code formatting changes

* Trying some ChatGPT stuff

* Getting rid of problematic experimentation

---------

Co-authored-by: Bram van Heuveln <[email protected]>
Co-authored-by: Charles Tian <[email protected]>
Co-authored-by: charlestian23 <[email protected]>

* Java21 (#714)

* Fixed Short Truth Table case rule bug (#707)

* Revert "Bugfix 549 (#682)"

This reverts commit 5048ee6.

* Case rule test fix (#705)

Co-authored-by: Chase Grajeda <[email protected]>

* Rapid fix for STT case rules

Case rules broke at some point from legacy code or merge conflict. Provided is a quick fix in CaseRule and CaseRule_Generic

* Revert "Revert "Bugfix 549 (#682)"" (#706)

This reverts commit e9fe310.

---------

Co-authored-by: Chase-Grajeda <[email protected]>
Co-authored-by: Chase Grajeda <[email protected]>

* Change Java version to 21 and setup JPackage to bundle Java with the app

* Setup gradle action for java 21

* Fix distribution in gradle.yml

* Fix java version in tests

* Fix java distribution in tests

* Add jpackage task

* Add Linux to jpackage task

* Fix jpackage task

* Add java setup to jpackage tasks

* Separate build into separate tasks for different operating systems

* Fix mac jpackage not working and changed names of artifacts

* Potential macos installer build fix

* Potential macos installer build fix attempt 2

* Potential macos installer build fix attempt 3

* Add quotes around executable name for macos installer

* Add logo and shortcut prompt

* Update version in build.gradle

* Make installer name different to app (It's a weird way to do it, it renames the file in a gradle task).

* Update java-autoformat.yml

Added check to make sure the pull request is not from a fork

---------

Co-authored-by: Charles Tian <[email protected]>
Co-authored-by: Chase-Grajeda <[email protected]>
Co-authored-by: Chase Grajeda <[email protected]>
Co-authored-by: charlestian23 <[email protected]>

* Update build.gradle (#741)

* Update build.gradle

Fixing the deprecation issues in the autoformatter

* Update build.gradle

* Update build.gradle

* Update to use Java 21

* Automated Java code formatting changes

---------

Co-authored-by: Bram van Heuveln <[email protected]>

* Updating to version 6.0.0

Changing to 6.0.0 since Java upgrade may break backwards compatibility

* Importer written

First draft of the importer written and setData refactored

* small bug fixes

* Added Puzzle Factory and Importer

Refactored a bunch of code so we now (in theory) import correctly

* Delete ThermometerExporter.java

* Added Thermometer to Config file

* Added necessary code to constructor

* Messing with Rule Recognition

* Fixing desyncs in repo

* More syncing and organizing files

* Small misc improvements

Further work on getting a file to open without errors

* Fixed verify vial method

* More work towards visual display

we now have semi working tials!

* Update ThermometerElementView.java

* Rotating images!!!!!

* Added in placeable elements

* Stabilizing bug fixes

* Import silliness

---------

Co-authored-by: Charles Tian <[email protected]>
Co-authored-by: Chase-Grajeda <[email protected]>
Co-authored-by: Chase Grajeda <[email protected]>
Co-authored-by: ThisMatt <[email protected]>
Co-authored-by: ThisMatt <[email protected]>
Co-authored-by: Jaden Tian <[email protected]>
Co-authored-by: Bram van Heuveln <[email protected]>
Co-authored-by: charlestian23 <[email protected]>
Co-authored-by: Fisher Luba <[email protected]>
Co-authored-by: Fuzzabee <[email protected]>
  • Loading branch information
11 people authored Apr 2, 2024
1 parent 4c966f4 commit 2394d17
Show file tree
Hide file tree
Showing 51 changed files with 468 additions and 178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import java.util.ArrayList;

import static edu.rpi.legup.puzzle.thermometer.ThermometerVial.verifyVial;

public class ThermometerBoard extends GridBoard{

//an array containing all of our vials on the board
Expand Down Expand Up @@ -87,9 +85,15 @@ public int getColNumber(int col){
public ArrayList<Integer> getColNumbers() { return colNumbers; }


//we all suck at programming so instead of using provided array list
//instead just trusting vials to store the cells for us
@Override
public ThermometerCell getCell(int x, int y){
if(x < 0 || y < 0 || x > dimension.height || y > dimension.width) return null;
return (ThermometerCell) super.getCell(x, y);
public ThermometerCell getCell(int x, int y) {
for(ThermometerVial vial: this.thermometerVials) {
for(ThermometerCell cell: vial.getCells()){
if(cell.getLocation().x == x && cell.getLocation().y == y) return cell;
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@ public class ThermometerCell extends GridCell<Integer> {
private ThermometerType type;
private ThermometerFill fill;
private int rotation;
public ThermometerCell(Point location) {
public ThermometerCell(Point location, ThermometerType t, ThermometerFill f, int r) {
//since we do not use get/set data value int can be any value
super(0, location);
type = ThermometerType.UNKNOWN;
fill = ThermometerFill.UNKNOWN;
rotation = 0;
type = t;
fill = f;
rotation = r;
}




//Note: setdata does not work for our purposes
public void setType(ThermometerType t){
type = t;
}


public ThermometerType getType() {
return switch (type.ordinal()) {
case 0 -> ThermometerType.UNKNOWN;
Expand Down Expand Up @@ -54,7 +50,7 @@ public ThermometerFill getFill() {

@Override
public ThermometerCell copy() {
ThermometerCell copy = new ThermometerCell((Point) location.clone());
ThermometerCell copy = new ThermometerCell((Point) location.clone(), this.type, this.fill, this.rotation);
copy.setIndex(index);
copy.setModifiable(isModifiable);
copy.setGiven(isGiven);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void initializeBoard(Node node) throws InvalidFileFormatException {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (thermometerBoard.getCell(x, y) == null) {
throw new InvalidFileFormatException("Undefined tile at (" + x + "," + y + ")");
throw new InvalidFileFormatException("Thermometer importer Undefined tile at (" + x + "," + y + ")");
}
}
}
Expand Down
58 changes: 12 additions & 46 deletions src/main/java/edu/rpi/legup/puzzle/thermometer/ThermometerVial.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ThermometerVial {
private ArrayList<ThermometerCell> cells;

public ThermometerVial(int headX, int headY, int tipX, int tipY, ThermometerBoard board) {
cells = new ArrayList<>();
cells = new ArrayList<ThermometerCell>();
fillData(headX, headY, tipX, tipY, board);
}

Expand Down Expand Up @@ -53,16 +53,18 @@ else if (headX < tipX){

//helper function for adding a single cell
private void addCell(int x, int y, ThermometerType t, int rotation, ThermometerBoard board){
ThermometerCell cell = new ThermometerCell(new Point(x, y));
ThermometerCell cell = new ThermometerCell(new Point(x, y), t, ThermometerFill.EMPTY, rotation);
cell.setIndex(y * board.getHeight() + x);
cell.setModifiable(true);
this.cells.add(cell);
//still important for element view stuff
board.setCell(x, y, cell);
board.getCell(x, y).setType(t);
board.getCell(x, y).setFill(ThermometerFill.EMPTY);
board.getCell(x,y).setRotation(rotation);
cells.add(board.getCell(x, y));
}


//TODO DOES NOT WORK AS INTENDED
// BECAUSE MOST RULES GET A PUZZLE ELEMENT PASSED IN AND WEIRD
// TYPE CASTING STUFF, PAY ATTENTION TO THIS WHEN WE START
// DEBUGGING RULES
//a basic accessor to check if a cell is contained in vial
public boolean containsCell(ThermometerCell cell){
for (ThermometerCell c : cells) {
Expand All @@ -73,8 +75,9 @@ public boolean containsCell(ThermometerCell cell){
return false;
}

public ThermometerCell getHead(){return cells.get(0);}
public ThermometerCell getTail(){return cells.get(cells.size());}
public ThermometerCell getHead(){return cells.getFirst();}
public ThermometerCell getTail(){return cells.getLast();}
public ArrayList<ThermometerCell> getCells(){return cells;}

//checking for discontinuous flow inside of vial
public boolean continuousFlow(){
Expand All @@ -91,41 +94,4 @@ public boolean continuousFlow(){
return true;
}


//used before calling the constructor to make sure the vial we are attempting to add is valid
public static boolean verifyVial(ThermometerCell headCell, ThermometerCell tipCell, ThermometerBoard board) {
//shorthand for useful variables
int headX = (int) headCell.getLocation().getX();
int headY = (int) headCell.getLocation().getY();
int tipX = (int) tipCell.getLocation().getX();
int tipY = (int) tipCell.getLocation().getY();


//figuring out which axis the thermometer travels along
if(headX == tipX) {
//finding start and end of Vial
int top = min(headY, tipY);
int bottom = max(headY, tipY);

//verifying that every cell along path is currently unclaimed
for (int i = top; i < bottom; i++) {
if(board.getCell(headX, i) != null || board.getCell(headX, i).getType() != ThermometerType.UNKNOWN) return false;
}
}
else if (headY == tipY) {
//finding start and end of Vial
int top = min(headX, tipX);
int bottom = max(headX, tipX);

//verifying that every cell along path is currently unclaimed
for (int i = top; i < bottom; i++) {
if(board.getCell(i, headY).getType() != ThermometerType.UNKNOWN) return false;
}
}
else{
//thermometer does not line up along a single axis
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import java.awt.*;

import static edu.rpi.legup.puzzle.thermometer.ThermometerVial.verifyVial;
import static java.lang.Math.max;
import static java.lang.Math.min;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ public class ThermometerView extends GridBoardView {
public ThermometerView(ThermometerBoard board) {
super(new BoardController(), new ThermometerController(), board.getDimension());

for (PuzzleElement puzzleElement : board.getPuzzleElements()) {
ThermometerCell cell = (ThermometerCell) puzzleElement;
Point loc = cell.getLocation();
ThermometerElementView elementView = new ThermometerElementView(cell);
elementView.setIndex(cell.getIndex());
elementView.setSize(elementSize);
elementView.setLocation(new Point(loc.x * elementSize.width, loc.y * elementSize.height));
elementViews.add(elementView);
for(ThermometerVial vial : board.getVials()) {
for(ThermometerCell cell : vial.getCells()) {
Point loc = cell.getLocation();
ThermometerElementView elementView = new ThermometerElementView(cell);
elementView.setIndex(cell.getIndex());
elementView.setSize(elementSize);
elementView.setLocation(new Point(loc.x * elementSize.width, loc.y * elementSize.height));
elementViews.add(elementView);
}
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileBlckE extends PlaceableElement {
public HeadTileBlckE(){
super("Therm-PLAC-0001",
"Head Tile Block East",
"The tile corresponding to the blocked head of an east thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadBlockE.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileBlckN extends PlaceableElement {
public HeadTileBlckN(){
super("Therm-PLAC-0002",
"Head Tile Block North",
"The tile corresponding to the blocked head of a north thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadBlockN.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileBlckS extends PlaceableElement {
public HeadTileBlckS(){
super("Therm-PLAC-0003",
"Head Tile Block South",
"The tile corresponding to the blocked head of a south thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadBlockS.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileBlckW extends PlaceableElement {
public HeadTileBlckW(){
super("Therm-PLAC-0004",
"Head Tile Block West",
"The tile corresponding to the blocked head of a west thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadBlockW.png");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileEmpE extends PlaceableElement {
public HeadTileEmpE(){
super("Therm-PLAC-0005",
"Head Tile Empty East",
"The tile corresponding to the empty head of an east thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadEmpE.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileEmpN extends PlaceableElement {
public HeadTileEmpN(){
super("Therm-PLAC-0006",
"Head Tile Empty North",
"The tile corresponding to the empty head of a North thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadEmpN.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileEmpS extends PlaceableElement {
public HeadTileEmpS(){
super("Therm-PLAC-0007",
"Head Tile Empty South",
"The tile corresponding to the empty head of a south thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadEmpS.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileEmpW extends PlaceableElement {
public HeadTileEmpW(){
super("Therm-PLAC-0008",
"Head Tile Empty West",
"The tile corresponding to the empty head of a west thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadEmpW.png");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileFillE extends PlaceableElement {
public HeadTileFillE(){
super("Therm-PLAC-0009",
"Head Tile Filled East",
"The tile corresponding to the filled head of an east thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadFillE.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileFillN extends PlaceableElement {
public HeadTileFillN(){
super("Therm-PLAC-0010",
"Head Tile Filled North",
"The tile corresponding to the filled head of a north thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadFillN.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileFillS extends PlaceableElement {
public HeadTileFillS(){
super("Therm-PLAC-0011",
"Head Tile Filled South",
"The tile corresponding to the filled head of a south thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadFillS.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package edu.rpi.legup.puzzle.thermometer.elements;

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

public class HeadTileFillW extends PlaceableElement {
public HeadTileFillW(){
super("Therm-PLAC-0012",
"Head Tile Filled West",
"The tile corresponding to the filled head of a west thermometer",
"edu/rpi/legup/images/thermometer/Elements/HeadFillW.png");
}
}
Loading

0 comments on commit 2394d17

Please sign in to comment.