From d26a1bec3d9966809b13a265703d9739d6e76927 Mon Sep 17 00:00:00 2001 From: tdou25 Date: Wed, 26 Jun 2024 21:01:47 -0400 Subject: [PATCH 1/2] began work on sudoku puzzle maker --- .../sudoku/rules/PossibleCellsByXWing.java | 107 ++++++++++++++++++ src/main/resources/edu/rpi/legup/legup/config | 2 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 src/main/java/edu/rpi/legup/puzzle/sudoku/rules/PossibleCellsByXWing.java diff --git a/src/main/java/edu/rpi/legup/puzzle/sudoku/rules/PossibleCellsByXWing.java b/src/main/java/edu/rpi/legup/puzzle/sudoku/rules/PossibleCellsByXWing.java new file mode 100644 index 000000000..2af727cd4 --- /dev/null +++ b/src/main/java/edu/rpi/legup/puzzle/sudoku/rules/PossibleCellsByXWing.java @@ -0,0 +1,107 @@ +package edu.rpi.legup.puzzle.sudoku.rules; + +import edu.rpi.legup.model.gameboard.Board; +import edu.rpi.legup.model.gameboard.CaseBoard; +import edu.rpi.legup.model.gameboard.PuzzleElement; +import edu.rpi.legup.model.rules.CaseRule; +import edu.rpi.legup.model.tree.TreeTransition; +import edu.rpi.legup.puzzle.sudoku.GroupType; +import edu.rpi.legup.puzzle.sudoku.ModelSudokuBoard; +import edu.rpi.legup.puzzle.sudoku.SudokuBoard; +import edu.rpi.legup.puzzle.sudoku.SudokuCell; +import java.util.ArrayList; +import java.util.Set; + +public class PossibleCellsByXWing extends CaseRule{ + + // Board math for translating indexes to numbers + private ModelSudokuBoard model = new ModelSudokuBoard(); + + // Old board for caseBoard reference + private SudokuBoard lagBoard; + + public PossibleCellsByXWing(){ + super("SUDO-CASE-0005", + "Possible X-Wing Cells.", + "If in two rows and two columns, four cells exist that will allow for the same number such that they form a rectangle," + + " that number must ocupy either one of the vertices of the rectangle.", + "edu/rpi/legup/images/sudoku/PossibleValues.png"); + } + + /** + * Checks whether the transition logically follows from the parent node using this rule + * + * @param transition transition to check + * @return null if the child node logically follow from the parent node, otherwise error message + */ + @Override + public String checkRuleRaw(TreeTransition transition) { + return null; + } + + /** + * Checks whether the child node logically follows from the parent node at the specific + * puzzleElement index using this rule + * + * @param transition transition to check + * @param puzzleElement equivalent puzzleElement + * @return null if the child node logically follow from the parent node at the specified + * puzzleElement, otherwise error message + */ + @Override + public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) { + return null; + } + + @Override + public CaseBoard getCaseBoard(Board board) { + SudokuBoard sudokuBoard = (SudokuBoard) board.copy(); + lagBoard = (SudokuBoard) sudokuBoard.copy(); + CaseBoard caseBoard = new CaseBoard(sudokuBoard, this); + for (PuzzleElement puzzleElement : sudokuBoard.getPuzzleElements()) { + puzzleElement.setData(model.getModelRegionNumbers(puzzleElement.getIndex())); + caseBoard.addPickableElement(puzzleElement); + } + return caseBoard; + } + + /** + * Gets the possible cases at a specific location based on this case rule + * + * @param board the current board state + * @param puzzleElement equivalent puzzleElement + * @return a list of elements the specified could be + */ + @Override + public ArrayList getCases(Board board, PuzzleElement puzzleElement) { + return getCases(board, puzzleElement, 1, GroupType.REGION); + } + + /** + * Gets the possible cases at a specific location based on this case rule + * + * @param board the current board state + * @param puzzleElement equivalent puzzleElement + * @param value value that the rule will be applied from + * @param groupType group type + * @return a list of elements the specified could be + */ + public ArrayList getCases( + Board board, PuzzleElement puzzleElement, int value, GroupType groupType) { + ArrayList cases = new ArrayList<>(); + SudokuBoard sudokuBoard = lagBoard; + SudokuCell sourceCell = (SudokuCell) puzzleElement; + + Set group = sudokuBoard.getRegion(sourceCell.getGroupIndex()); + for (SudokuCell cell : group) { + if (cell.getData() == 0) { + Board newCase = sudokuBoard.copy(); + PuzzleElement element = newCase.getPuzzleElement(cell); + element.setData(model.getModelRegionNumbers(sourceCell.getIndex())); + newCase.addModifiedData(element); + cases.add(newCase); + } + } + return cases; + } +} diff --git a/src/main/resources/edu/rpi/legup/legup/config b/src/main/resources/edu/rpi/legup/legup/config index b31d7bd0e..9c1b3f56d 100644 --- a/src/main/resources/edu/rpi/legup/legup/config +++ b/src/main/resources/edu/rpi/legup/legup/config @@ -34,7 +34,7 @@ fileCreationDisabled="false"/> + fileCreationDisabled="false"/> Date: Fri, 28 Jun 2024 14:23:29 -0400 Subject: [PATCH 2/2] added tile image --- .../legup/images/sudoku/tiles/NumberTile.png | Bin 0 -> 10067 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/resources/edu/rpi/legup/images/sudoku/tiles/NumberTile.png diff --git a/src/main/resources/edu/rpi/legup/images/sudoku/tiles/NumberTile.png b/src/main/resources/edu/rpi/legup/images/sudoku/tiles/NumberTile.png new file mode 100644 index 0000000000000000000000000000000000000000..5a8540d02b509f12c7f059648bbadf021efcedda GIT binary patch literal 10067 zcmeHLc{G&m`ya9|k!(qtrq^0yR%T2F*_AcQ9%Bq9W`>!uhGfYSMY3cIp_Hs8S)yze zQFgLK$`Y?VO7a`(ecw92?>WEop7ZST^wwTUz(raG628=^E0!cpTcd>Ri7Xt6^<~q4zLUSOyHD@f4Z5cU$zhkeuntC`(0FsR_V@+&$Uf~hYaZE9 z-lUWAdQCv`dO}Y;>QTn0Yk1D3{YthXEFi6-^{&ON3vo-`b;E?{Z!caGX!4J^7c63Z zoG1HqrL!Zm4_xXX*nVd93O5g!Yhk5+tL*mTgH+NCoi8FZ^L<_NbmKT!=Pq?XwQBOps1;40m5i7EO7FOOZU^TdS=D6>L4~w^2_ZtYd+da;`>=KrtQ)|v_Z5;`Vq=wdD>xzSe!Nq>NtM?g-I~H(A@xXcI*9xs67zdh0+!eiHn>?Oe=yQe8;aoju3x&wq|LV zoucw}oc8)%FyF=CFyCT=DeWUT+46y-(mDE@W`1x}vV-9@!HEo`LzYppxoIWNmp()% z(QC*&xU%2dd>~@+K19J%-vC=x%9h`6@>*9UMO(_*USB-KV;5_5XyS{0 z;eMqXtp;u7f861M0H&l-G17SZ*Pc=fAqyYdhD2zPCGA80EvePd#0{oZ?EieZ-}9Ky z`8uoAk@8B>xA)w8-sRmqiVm!qT#M%1(@RkZLZ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