X-Git-Url: http://git.scottworley.com/slidingtile/blobdiff_plain/537a8dc7ce26e6ab5cf3c82ecce388d08566a8b8..1955dd8bceb1bd5beef449ff1ac04c35c2714f31:/sliding_tile_lib.cc diff --git a/sliding_tile_lib.cc b/sliding_tile_lib.cc index 9f6bfc9..51aeded 100644 --- a/sliding_tile_lib.cc +++ b/sliding_tile_lib.cc @@ -12,6 +12,7 @@ #include +int Step::count = 0; signed char Step::adjacent[BOARD_SIZE][5] = { 1, 4, -1, -1, -1, 0, 2, 5, -1, -1, @@ -138,7 +139,13 @@ int Board::distance(const InvertedBoard& invo) const { return dist; } -Step::Step(Board board, std::shared_ptr prev) : board(board), prev(prev) {} +Step::Step(Board board, std::shared_ptr prev) : board(board), prev(prev) { + count++; +} + +Step::~Step() { + count--; +} std::vector> Step::successors(std::shared_ptr shared_this) const { std::vector> suc; @@ -215,7 +222,8 @@ std::shared_ptr find_path(const Board& start, const Board& goal) { seen.emplace(s->board); todo.push(s); if (seen.size() % 10000 == 0) { - std::cerr << "Examined " << seen.size() << " boards. " << todo.size() + std::cerr << "Examined " << seen.size() << " boards. Tracking " + << Step::count << " steps. " << todo.size() << " waiting. Considering paths of length " << todo.top()->cost(invgoal) << std::endl; }