Skip to content

Commit 138be39

Browse files
committed
some updates
added stuff to test suites and changed a board
1 parent 4e54050 commit 138be39

File tree

6 files changed

+103
-2
lines changed

6 files changed

+103
-2
lines changed

puzzles files/minesweeper/7x7 Minesweeper Medium/Minesweeper 7x7 medium 3

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<cell value="0" x="1" y="3"/>
2020
<cell value="0" x="1" y="4"/>
2121
<cell value="3" x="2" y="4"/>
22+
<cell value="3" x="2" y="5"/>
23+
<cell value="-2" x="2" y="6"/>
24+
<cell value="3" x="4" y="6"/>
2225
<cell value="3" x="6" y="6"/>
2326
<cell value="3" x="2" y="0"/>
2427
<cell value="3" x="0" y="2"/>

src/test/java/puzzles/minesweeper/NonTouchingSharedEmptyDirectRuleTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,32 @@ public void NonTouchingSharedEmptyDirectRule_VerticalTest2() throws InvalidFileF
162162
}
163163
}
164164
}
165+
166+
@Test
167+
public void NonTouchingSharedEmptyDirectRule_HorizontalTest() throws InvalidFileFormatException {
168+
TestUtilities.importTestBoard("puzzles/minesweeper/rules/NonSharedEmpty1.txt", minesweeper);
169+
TreeNode rootNode = minesweeper.getTree().getRootNode();
170+
TreeTransition transition = rootNode.getChildren().get(0);
171+
transition.setRule(RULE);
172+
173+
MinesweeperBoard board = (MinesweeperBoard) transition.getBoard();
174+
175+
MinesweeperCell cell1 = board.getCell(0, 0);
176+
cell1.setData(MinesweeperTileData.empty());
177+
178+
board.addModifiedData(cell1);
179+
180+
Assert.assertNull(RULE.checkRule(transition));
181+
182+
for (int i = 0; i < board.getHeight(); i++) {
183+
for (int k = 0; k < board.getWidth(); k++) {
184+
Point point = new Point(k, i);
185+
if (point.equals(cell1.getLocation())) {
186+
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
187+
} else {
188+
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
189+
}
190+
}
191+
}
192+
}
165193
}

src/test/java/puzzles/minesweeper/NonTouchingSharedMineDirectRuleTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,32 @@ public void NonTouchingSharedMineDirectRule_VerticalTest2() throws InvalidFileFo
183183
}
184184
}
185185
}
186+
187+
@Test
188+
public void NonTouchingSharedMineDirectRule_HorizontalTest() throws InvalidFileFormatException {
189+
TestUtilities.importTestBoard("puzzles/minesweeper/rules/NonSharedMine1.txt", minesweeper);
190+
TreeNode rootNode = minesweeper.getTree().getRootNode();
191+
TreeTransition transition = rootNode.getChildren().get(0);
192+
transition.setRule(RULE);
193+
194+
MinesweeperBoard board = (MinesweeperBoard) transition.getBoard();
195+
196+
MinesweeperCell cell1 = board.getCell(0, 0);
197+
cell1.setData(MinesweeperTileData.mine());
198+
199+
board.addModifiedData(cell1);
200+
201+
Assert.assertNull(RULE.checkRule(transition));
202+
203+
for (int i = 0; i < board.getHeight(); i++) {
204+
for (int k = 0; k < board.getWidth(); k++) {
205+
Point point = new Point(k, i);
206+
if (point.equals(cell1.getLocation())) {
207+
Assert.assertNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
208+
} else {
209+
Assert.assertNotNull(RULE.checkRuleAt(transition, board.getCell(k, i)));
210+
}
211+
}
212+
}
213+
}
186214
}

src/test/java/puzzles/minesweeper/TooFewMinesContradictionRuleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static void setUp() {
2222

2323
@Test
2424
// tests a 3x3 board with a 3 in the center surrounded by 2 mines and 6 empty
25-
public void TooManyMinesTest1() throws InvalidFileFormatException {
25+
public void TooFewMinesTest1() throws InvalidFileFormatException {
2626
TestUtilities.importTestBoard("puzzles/minesweeper/rules/TooFewMines1.txt", minesweeper);
2727
TreeNode rootNode = minesweeper.getTree().getRootNode();
2828
TreeTransition transition = rootNode.getChildren().get(0);
@@ -46,7 +46,7 @@ public void TooManyMinesTest1() throws InvalidFileFormatException {
4646

4747
@Test
4848
// tests a 3x3 board with a 3 in the center surrounded by 2 unset and 6 empty
49-
public void TooManyMinesTest2() throws InvalidFileFormatException {
49+
public void TooFewMinesTest2() throws InvalidFileFormatException {
5050
TestUtilities.importTestBoard("puzzles/minesweeper/rules/TooFewMines2.txt", minesweeper);
5151
TreeNode rootNode = minesweeper.getTree().getRootNode();
5252
TreeTransition transition = rootNode.getChildren().get(0);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<Legup version="3.0.0">
3+
<puzzle name="Minesweeper" tag="NonSharedMine1">
4+
<board height="4" width="4">
5+
<cells>
6+
<cell value="0" x="1" y="0"/>
7+
<cell value="0" x="2" y="0"/>
8+
<cell value="0" x="0" y="1"/>
9+
<cell value="1" x="1" y="1"/>
10+
<cell value="0" x="3" y="1"/>
11+
<cell value="0" x="0" y="2"/>
12+
<cell value="1" x="2" y="2"/>
13+
<cell value="0" x="3" y="2"/>
14+
<cell value="0" x="1" y="3"/>
15+
<cell value="0" x="2" y="3"/>
16+
<cell value="0" x="3" y="3"/>
17+
</cells>
18+
</board>
19+
</puzzle>
20+
<solved isSolved="580151020" lastSaved="2025-04-17 16:34:55"/>
21+
</Legup>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<Legup version="3.0.0">
3+
<puzzle name="Minesweeper" tag="NonSharedMine1">
4+
<board height="4" width="4">
5+
<cells>
6+
<cell value="0" x="1" y="0"/>
7+
<cell value="0" x="2" y="0"/>
8+
<cell value="0" x="0" y="1"/>
9+
<cell value="2" x="1" y="1"/>
10+
<cell value="0" x="3" y="1"/>
11+
<cell value="0" x="0" y="2"/>
12+
<cell value="1" x="2" y="2"/>
13+
<cell value="0" x="3" y="2"/>
14+
<cell value="0" x="1" y="3"/>
15+
<cell value="0" x="2" y="3"/>
16+
<cell value="0" x="3" y="3"/>
17+
</cells>
18+
</board>
19+
</puzzle>
20+
<solved isSolved="580151020" lastSaved="2025-04-17 16:34:55"/>
21+
</Legup>

0 commit comments

Comments
 (0)