From ab51c07a99c1927c95a123e6912925adba83714f Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 9 Jan 2016 22:00:10 -0800 Subject: [PATCH] Don't constrain the hole. --- sliding_tile_lib.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sliding_tile_lib.cc b/sliding_tile_lib.cc index 51aeded..9ac0217 100644 --- a/sliding_tile_lib.cc +++ b/sliding_tile_lib.cc @@ -133,8 +133,10 @@ int Board::distance(const Board& o) const { int Board::distance(const InvertedBoard& invo) const { int dist = 0; for (int i = 0; i < BOARD_SIZE; i++) { - dist += std::abs(i % BOARD_DIM - invo.pos[board[i]] % BOARD_DIM) + - std::abs(i / BOARD_DIM - invo.pos[board[i]] / BOARD_DIM); + if (board[i] != 0) { + dist += std::abs(i % BOARD_DIM - invo.pos[board[i]] % BOARD_DIM) + + std::abs(i / BOARD_DIM - invo.pos[board[i]] / BOARD_DIM); + } } return dist; } -- 2.44.1