]> git.scottworley.com Git - slidingtile/blob - find_long_distance_boards.cc
22c6c2e6e9ce09aab2a592553f108a8f59c48a61
[slidingtile] / find_long_distance_boards.cc
1 #include "sliding_tile_lib.h"
2 #include "gflags/gflags.h"
3
4 #include <iostream>
5 #include <random>
6
7 int main(int argc, char** argv) {
8 gflags::ParseCommandLineFlags(&argc, &argv, false);
9
10 Board goal{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}};
11 InvertedBoard invgoal = goal.invert();
12
13 Board rev{{0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}};
14 std::cout << rev.distance(invgoal) << ": " << rev << std::endl;
15
16 std::random_device rd;
17 std::mt19937 rng(rd());
18
19 int max_distance = 0;
20 while (true) {
21 Board b{{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}};
22 for (int i = 0; i < BOARD_SIZE; i++) {
23 std::uniform_int_distribution<> get_random_number(0, i);
24 std::swap(b.board[i], b.board[get_random_number(rng)]);
25 }
26 int dist = b.distance(invgoal);
27 if (dist > max_distance) {
28 max_distance = dist;
29 }
30 if (dist > max_distance - 2) {
31 std::cout << dist << ": " << b << std::endl;
32 }
33 }
34 }