]>
git.scottworley.com Git - slidingtile/blob - find_long_distance_boards.cc
1 #include "sliding_tile_lib.h"
2 #include "gflags/gflags.h"
7 int main(int argc
, char** argv
) {
8 gflags::ParseCommandLineFlags(&argc
, &argv
, false);
10 Board goal
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}};
11 InvertedBoard invgoal
= goal
.invert();
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
;
16 std::random_device rd
;
17 std::mt19937
rng(rd());
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
)]);
26 int dist
= b
.distance(invgoal
);
27 if (dist
> max_distance
) {
30 if (dist
> max_distance
- 2) {
31 std::cout
<< dist
<< ": " << b
<< std::endl
;