Skip to content

Commit

Permalink
Fix broken tests for #171.
Browse files Browse the repository at this point in the history
  • Loading branch information
donkirkby committed Nov 15, 2021
1 parent 7859366 commit a56f5a5
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
2 changes: 2 additions & 0 deletions bees.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ def has_touching_blanks(self):
def count_gaps(positions: typing.Set[typing.Tuple[int, int]],
width: int,
height: int):
if not positions:
return 0
unvisited = set(positions)
max_gap = width + height
old_total = max_gap * len(unvisited)
Expand Down
1 change: 1 addition & 0 deletions drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def generate_moves(self, board: DriversBoard) -> typing.Iterator[
total_gaps = self.check_progress(board)
yield MoveDescription(move,
combined_display,
heuristic=total_gaps,
remaining=total_gaps)
positions.reverse()
dice_set.move(*positions)
Expand Down
24 changes: 21 additions & 3 deletions raw_rules/new_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ Here are the starting positions for several Donimo Drivers problems. The
solutions are listed at the end.

#### Problem 1
4|4 4|3

0|0 1 1
- -
2|4 0 1

#### Problem 2
3|4 2|2 3 4
- -
3|2 0|2 3 4
Expand All @@ -54,7 +61,16 @@ solutions are listed at the end.

1|3 1|1 1|2

#### Problem 2
#### Problem 3
4 1|1 0|1
-
3 3 4 0|0
- -
3 0 0 4|4
-
2 4|2 1|3

#### Problem 4
3|3 4|0 0|2

4 1 0|0 2|3
Expand Down Expand Up @@ -221,8 +237,10 @@ distance. For example, 1R3 means move the 1 die to the right, 3 spaces. A move
with no distance means one space. The driving moves have a small letter 'd' for
'domino' after the die number, like 1dR.

1. 3D, 3R, 3R, 3R, 3R, 3dU, 4dU, 2L, 2L, 2U, 2U, 2U, 2dR
2. 4dD, 4U, 4L2, 4U, 4dR, 4U3, 4L2, 2dR, 4dR, 3dR, 4D, 4L3, 4dU, 1dU, 1R2, 2L2,
1. 3dR, 4dL, 1L, 1U, 1dU
2. 3D, 3R4, 3dU, 4dU, 2L2, 2U3, 2dR
3. 1L2, 2dD, 3L2, 3U, 3L, 3U, 4dD, 1dL2, 3dU, 4R2, 4dU
4. 4dD, 4U, 4L2, 4U, 4dR, 4U3, 4L2, 2dR, 4dR, 3dR, 4D, 4L3, 4dU, 1dU, 1R2, 2L2,
2D, 2L3, 2D, 2L, 2dD, 2R, 2U2, 2R3, 2U, 2R2, 4dD, 4R3, 4U, 3dL, 4dL, 2dL, 1dR
## Adding Donimoes Solutions
Here are the solutions to the Adding Donimoes problems. For each step, move the
Expand Down
45 changes: 36 additions & 9 deletions test_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,26 @@ def test_move_unforced():
---
dice:(0,2)1,(3,1)2
"""
expected_moves = [MoveDescription('1R', expected_display1, remaining=1),
MoveDescription('1dL', expected_display2, remaining=2),
MoveDescription('2L', expected_display3, remaining=1),
MoveDescription('2dU', expected_display4, remaining=1),
MoveDescription('2dD', expected_display5, remaining=1)]
expected_moves = [MoveDescription('1R',
expected_display1,
heuristic=1,
remaining=1),
MoveDescription('1dL',
expected_display2,
heuristic=2,
remaining=2),
MoveDescription('2L',
expected_display3,
heuristic=1,
remaining=1),
MoveDescription('2dU',
expected_display4,
heuristic=1,
remaining=1),
MoveDescription('2dD',
expected_display5,
heuristic=1,
remaining=1)]
graph = DriversGraph()

moves = list(graph.generate_moves(board))
Expand All @@ -155,7 +170,10 @@ def test_move_forced():
---
dice:(0,1)1,(3,1)2
"""
expected_moves = [MoveDescription('1L', expected_display1, remaining=1)]
expected_moves = [MoveDescription('1L',
expected_display1,
heuristic=1,
remaining=1)]
graph = DriversGraph()

moves = list(graph.generate_moves(board))
Expand All @@ -180,7 +198,10 @@ def test_move_two_dice():
---
dice:(0,1)1,(1,1)2
"""
expected_moves = [MoveDescription('1dL', expected_display, remaining=1)]
expected_moves = [MoveDescription('1dL',
expected_display,
heuristic=1,
remaining=1)]
graph = DriversGraph()

moves = list(graph.generate_moves(board))
Expand Down Expand Up @@ -213,8 +234,14 @@ def test_move_stays_connected():
---
dice:(0,1)1
"""
expected_moves = [MoveDescription('1R', expected_display1, remaining=2),
MoveDescription('1dR', expected_display2, remaining=1)]
expected_moves = [MoveDescription('1R',
expected_display1,
heuristic=2,
remaining=2),
MoveDescription('1dR',
expected_display2,
heuristic=1,
remaining=1)]
graph = DriversGraph()

moves = list(graph.generate_moves(board))
Expand Down

0 comments on commit a56f5a5

Please sign in to comment.