Only loop through directions when a peg is present.
This commit is contained in:
parent
7dc37d4ede
commit
7db1769723
@ -53,11 +53,13 @@ class Solver
|
|||||||
{
|
{
|
||||||
for (int col = 0; col <= row; col++)
|
for (int col = 0; col <= row; col++)
|
||||||
{
|
{
|
||||||
|
if (board.peg_present(row, col))
|
||||||
|
{
|
||||||
|
Board.Position position = Board.Position(row, col);
|
||||||
for (Board.Direction direction = Board.Direction.FIRST;
|
for (Board.Direction direction = Board.Direction.FIRST;
|
||||||
direction < Board.Direction.COUNT;
|
direction < Board.Direction.COUNT;
|
||||||
direction++)
|
direction++)
|
||||||
{
|
{
|
||||||
Board.Position position = Board.Position(row, col);
|
|
||||||
Board new_board = board.move(position, direction);
|
Board new_board = board.move(position, direction);
|
||||||
if (new_board !is null)
|
if (new_board !is null)
|
||||||
{
|
{
|
||||||
@ -70,6 +72,7 @@ class Solver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!found_valid_move)
|
if (!found_valid_move)
|
||||||
{
|
{
|
||||||
end_game(board, moves);
|
end_game(board, moves);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user