Only loop through directions when a peg is present.
This commit is contained in:
parent
7dc37d4ede
commit
7db1769723
@ -53,19 +53,22 @@ class Solver
|
||||
{
|
||||
for (int col = 0; col <= row; col++)
|
||||
{
|
||||
for (Board.Direction direction = Board.Direction.FIRST;
|
||||
direction < Board.Direction.COUNT;
|
||||
direction++)
|
||||
if (board.peg_present(row, col))
|
||||
{
|
||||
Board.Position position = Board.Position(row, col);
|
||||
Board new_board = board.move(position, direction);
|
||||
if (new_board !is null)
|
||||
for (Board.Direction direction = Board.Direction.FIRST;
|
||||
direction < Board.Direction.COUNT;
|
||||
direction++)
|
||||
{
|
||||
found_valid_move = true;
|
||||
Move m = new Move(position, position.move(direction, 2));
|
||||
Move[] new_moves = moves.dup;
|
||||
new_moves ~= m;
|
||||
eval_board(new_board, new_moves);
|
||||
Board new_board = board.move(position, direction);
|
||||
if (new_board !is null)
|
||||
{
|
||||
found_valid_move = true;
|
||||
Move m = new Move(position, position.move(direction, 2));
|
||||
Move[] new_moves = moves.dup;
|
||||
new_moves ~= m;
|
||||
eval_board(new_board, new_moves);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user