That's kind of odd, how come it found the 10 move solution at depth 10, but not the 8+2 move solution at depth 8?
Because it pruned a candidate leaf node before passing it recursively on to (depth == 0) where the TFS databases "look ahead" beyond the current depth. It is very frustrating, but if I figure this out, the "depth" of the databases will functionally double. Here is what is going on:
Code:
void search_forever(BITBOARD_4x4x4_CUBE which_cube, unsigned short which_depth, signed short last_move_axis, signed short last_move_group, signed short move_just_made, unsigned short unchanging_depth)
{
if(move_just_made >= 0) GLOBAL_CUBE_SOLUTION[unchanging_depth - which_depth - 1] = move_just_made + 1;
if(which_depth == 0)
{
g_total_nodes++;
// if this is the "time to update" you get the full principal variation shown because all moves at the present depth have been generated
if(time_to_update()) {BUILD_PV_STRING SHOW_PV_STRING g_last_update = clock();}
if(bitboard_4x4x4_cube_is_solved_from_any_orientation(which_cube))
{
show_this_solution(unchanging_depth);
}
else
{
tfs_result = tfs_1_database_lookup(which_cube);
if(tfs_result >= 0)
{
show_this_solution_from_TFS_1_at_which_depth(unchanging_depth, tfs_result);
}
else
{
tfs_result = tfs_2_database_lookup(which_cube);
if(tfs_result >= 0)
{
show_this_solution_from_TFS_2_at_which_depth(unchanging_depth, tfs_result);
}
else
{
tfs_result = tfs_3_database_lookup(which_cube);
if(tfs_result >= 0)
{
show_this_solution_from_TFS_3_at_which_depth(unchanging_depth, tfs_result);
}
}
}
}
}
else
{
// if this is the "time to update" you will see ?? since the entire principal variation cant be drawn
if(time_to_update()) {BUILD_PV_STRING SHOW_PV_STRING g_last_update = clock();}
if(---PRUNING CONDITIONS---)
{
return;
}
//The Jakube Move Generator Move Ordering...
for(axis_of_rotation = 0; axis_of_rotation < 3; axis_of_rotation++)
{
for(move_group = 0; move_group < 4; move_group++)
{
if((axis_of_rotation != last_move_axis) || ((axis_of_rotation == last_move_axis) && (move_group > last_move_group)))
{
for(move_index = 0; move_index < 3; move_index++)
{
which_move_to_make = GLOBAL_AXIS_ROTATION[axis_of_rotation][move_group][move_index];
modified_cube = cube_move_array[which_move_to_make](which_cube);
search_forever(modified_cube, which_depth-1, axis_of_rotation, move_group, which_move_to_make, unchanging_depth);
}
}
}
}
}
}
So basically if pruning occurs down towards the bottom, it means a database query (like 3 moves left in the search tree, but the 3-turns database showed a miss, so that means no matter what 3 turns are left, the cube is not solved) rejects a node. Somehow, my depth count is off by 1, or, worse, a scramble entry can be optimized, so an 8-move scramble can be solved in 7 or less, so I am pruning GOOD SOLUTIONS from another rotated state before they have a chance to be tested when depth == 0. I think all I need to do is add 1 to my pruning depth condition, or maybe 2 for safety, and I should be able to prune 3 plies worth during move generation, and still see 3 moves "into the future" when depth ==0! If I am correct, this means
the 4-TFS could be used as a functional 8-TFS database, the 5-TFS could be used as a 10-TFS database, etc.
Oh, and how big is the turns-from-solved database compared to the old version, for a given size of moves? 35 MB sounds like a lot for just 3 TFS.
It is a lot, indeed. Just computing the counts for a given depth was a huge undertaking. I had to verify there were no duplicate positions in any one of 24 different cube orientations before I could add a single node to the count. I did it the hard way, with a 36^n move generator, and storing EVERY POSITION that passed the test of being unique, then adding that to the scan list for the next run of tests. Here are the position counts per depth:
Code:
#define TOTAL_POSITIONS_TFS_DEPTH_00 24
#define TOTAL_POSITIONS_TFS_DEPTH_01 864
#define TOTAL_POSITIONS_TFS_DEPTH_02 23976
#define TOTAL_POSITIONS_TFS_DEPTH_03 652464
#define TOTAL_POSITIONS_TFS_DEPTH_04 17917200
#define TOTAL_POSITIONS_TFS_DEPTH_05 490105728
#define TOTAL_POSITIONS_TFS_DEPTH_06 13406521248
#define TOTAL_POSITIONS_TFS_DEPTH_07 366726051072
Every position in the database is 48 bytes plus 1 byte per move in the solution plus 1 byte for the turncount (I might merge the data into one huge database some day) plus one byte for the rotation index. So 51 bytes per position in the 1-TFS, 52 bytes per 2-TFS position, 53 for 3-TFS, 54 for 4-TFS etc. Multiply this by the corresponding number above, and you the number of bytes of RAM you need.
The old code took too many shortcuts. Case in point: I did not store the positions, I stored a 64-bit hash number, only 8 bytes, per position. When I had "hash collisions" you saw weird moves in the "[inside TFS] --->" output. It worked in 99.999% of the cases, but when it failed, it was pretty bad. I also did not store rotated states, so it would only find positions that would arise from the original solving orientation. A vast majority of the solutions are of such a nature, but still, not the way to do it. So the old 6-TFS was something like 12 GB. The new scheme would be 699 GB

Slight difference.
Is it still practical for you to have 6 TFS on your own computer?
When 699 GB becomes commonplace, yes. You laugh, but in 1989, when I was working as a Mac software developer, we had 5 MB of RAM on our systems, and we laughed at the thought of ever having 1 GB of RAM someday.
If you are storing the same position for all 24 solved orientations, have you thought about ways to remove that problem, e.g. by 'normalizing' the color scheme (so doing a given 2 moves from solved gives the same database entry no matter what orientation the puzzle was in)? It may slow down computation of which database entry a position would correspond to, but I'm sure with some bit-twiddling cleverness you can make it pretty quick. I can't find the post, but I think I remember you storing every face as 16 4-bit sequences; would it be useful to store them as 0010, 0011, 0100, 0101, 1000, and 1001 (with the xxx0 and xxx1 being opposite)?
I only store the positions that are unique. For example, I solve all moves at depth 1 for an unrotated cube. Next, I do rotation #1 of 23. I start generating moves. I query the database as it is being built. If the same position already exists, even though coming from a different rotated state, I do not enter the position into the TFS database. Only unique positions are in there, so the databases have 0 wasted space. That is why it took so long for me to build them this time around. Lots of computation before allowing them in.
EDIT: Looks like Version 2.0.4 is finally handling the pruning properly.
http://lightningcloudcomputing.com/OO_4x4x4_204.zip