unsolved
Veteran
Yes, but why do you never have a pattern like 1122 or 1364? The way I understand what you're doing, any sequence of 4 digits (in 1-6) should be possible.
Well if you really want to see the full 4,210,105 characters of text in the entire matrix, here you go (but be prepared for your browser to have a heart attack):
lightningcloudcomputing.com/huge_matrix.txt
You are correct. 1111 to 6666 are possible, with any combination/permutation in between. But a face on the cube looks like this, row by row:
1111
1111
1111
1111
So if I move R', it moves one back row to the top, and the top will look like this:
1115
1115
1115
1115
If I move f next, then the left slice cuts across the top
1115
1115
6666
1115
There are many sequences that don't disturb the top at all, such as U, U', u, u', D, D', d, d', U2, etc. While the rotations move the cubes, the numbers there do not change.
By the way, while writing code with a program may be fun, I don't recommend it for a final version. The most you should do automatically is generate arrays of data. Any code where someone might go "what are all these magic numbers for" is just going to end up hard to maintain, and will probably need to be completely redone whenever you change something.
I was a professional coder for a number of years, but thank you. This is a very new project, far from polished, far from finished. To see what one of my totally polished, final products looks like:
Free to download if you like a game that's even more challenging than chess:
http://www.lightningcloudcomputing.com/vortex.zip
wait, are you representing the cube using stickers instead of pieces? that just seems as though it would take longer to implement, be more complicated, and make the code less intuitive to understand (example: "case 1141: index_start = 218184; index_stop = 246384; break;" - it's definitely not obvious what that is supposed to mean)
I do all of my prototyping at the facet level, or, as you say, "using stickers." It makes the code relatively easy to understand at 2 in the morning when I "have a great idea"
Code:
CUBE_4x4_ARRANGEMENT minus_top_face_move(CUBE_4x4_ARRANGEMENT original_4x4x4_cube)
{
CUBE_4x4_ARRANGEMENT new_cube;
new_cube = original_4x4x4_cube;
new_cube.cube_front[0] = original_4x4x4_cube.cube_left[0];
new_cube.cube_front[1] = original_4x4x4_cube.cube_left[1];
new_cube.cube_front[2] = original_4x4x4_cube.cube_left[2];
new_cube.cube_front[3] = original_4x4x4_cube.cube_left[3];
new_cube.cube_right[0] = original_4x4x4_cube.cube_front[0];
new_cube.cube_right[1] = original_4x4x4_cube.cube_front[1];
new_cube.cube_right[2] = original_4x4x4_cube.cube_front[2];
new_cube.cube_right[3] = original_4x4x4_cube.cube_front[3];
new_cube.cube_back[0] = original_4x4x4_cube.cube_right[0];
new_cube.cube_back[1] = original_4x4x4_cube.cube_right[1];
new_cube.cube_back[2] = original_4x4x4_cube.cube_right[2];
new_cube.cube_back[3] = original_4x4x4_cube.cube_right[3];
new_cube.cube_left[0] = original_4x4x4_cube.cube_back[0];
new_cube.cube_left[1] = original_4x4x4_cube.cube_back[1];
new_cube.cube_left[2] = original_4x4x4_cube.cube_back[2];
new_cube.cube_left[3] = original_4x4x4_cube.cube_back[3];
/*********************************/
/* * * * */
/* 01 * 02 * 03 * 04 */
/* * * * */
/*********************************/
/* * * * */
/* 05 * 06 * 07 * 08 */
/* * * * */
/*********************************/
/* * * * */
/* 09 * 10 * 11 * 12 */
/* * * * */
/*********************************/
/* * * * */
/* 13 * 14 * 15 * 16 */
/* * * * */
/*********************************/
/*********************************/
/* * * * */
/* 04 * 08 * 12 * 16 */
/* * * * */
/*********************************/
/* * * * */
/* 03 * 07 * 11 * 15 */
/* * * * */
/*********************************/
/* * * * */
/* 02 * 06 * 10 * 14 */
/* * * * */
/*********************************/
/* * * * */
/* 01 * 05 * 09 * 13 */
/* * * * */
/*********************************/
new_cube.cube_top[1-1] = original_4x4x4_cube.cube_top[4-1];
new_cube.cube_top[2-1] = original_4x4x4_cube.cube_top[8-1];
new_cube.cube_top[3-1] = original_4x4x4_cube.cube_top[12-1];
new_cube.cube_top[4-1] = original_4x4x4_cube.cube_top[16-1];
new_cube.cube_top[5-1] = original_4x4x4_cube.cube_top[3-1];
new_cube.cube_top[6-1] = original_4x4x4_cube.cube_top[7-1];
new_cube.cube_top[7-1] = original_4x4x4_cube.cube_top[11-1];
new_cube.cube_top[8-1] = original_4x4x4_cube.cube_top[15-1];
new_cube.cube_top[9-1] = original_4x4x4_cube.cube_top[2-1];
new_cube.cube_top[10-1] = original_4x4x4_cube.cube_top[6-1];
new_cube.cube_top[11-1] = original_4x4x4_cube.cube_top[10-1];
new_cube.cube_top[12-1] = original_4x4x4_cube.cube_top[14-1];
new_cube.cube_top[13-1] = original_4x4x4_cube.cube_top[1-1];
new_cube.cube_top[14-1] = original_4x4x4_cube.cube_top[5-1];
new_cube.cube_top[15-1] = original_4x4x4_cube.cube_top[9-1];
new_cube.cube_top[16-1] = original_4x4x4_cube.cube_top[13-1];
return new_cube;
}
But I also have a lean, mean bitboard implementation, which is not so easy to read or understand, but it runs much, much faster on massively parallel hardware at my office.
Code:
CUBE_4x4_BITBOARD_ARRANGEMENT minus_top_face_bitboard_move(CUBE_4x4_BITBOARD_ARRANGEMENT original_4x4x4_bitboard_cube)
{
CUBE_4x4_BITBOARD_ARRANGEMENT new_bitboard_cube = original_4x4x4_bitboard_cube;
new_bitboard_cube.cube_face[FRONT_INDEX] = (original_4x4x4_bitboard_cube.cube_face[FRONT_INDEX] & BITMASK_CUBE_FACE_NOT_ROW_01) | (original_4x4x4_bitboard_cube.cube_face[LEFT_INDEX] & BITMASK_CUBE_FACE_ROW_01);
new_bitboard_cube.cube_face[RIGHT_INDEX] = (original_4x4x4_bitboard_cube.cube_face[RIGHT_INDEX] & BITMASK_CUBE_FACE_NOT_ROW_01) | (original_4x4x4_bitboard_cube.cube_face[FRONT_INDEX] & BITMASK_CUBE_FACE_ROW_01);
new_bitboard_cube.cube_face[BACK_INDEX] = (original_4x4x4_bitboard_cube.cube_face[BACK_INDEX] & BITMASK_CUBE_FACE_NOT_ROW_01) | (original_4x4x4_bitboard_cube.cube_face[RIGHT_INDEX] & BITMASK_CUBE_FACE_ROW_01);
new_bitboard_cube.cube_face[LEFT_INDEX] = (original_4x4x4_bitboard_cube.cube_face[LEFT_INDEX] & BITMASK_CUBE_FACE_NOT_ROW_01) | (original_4x4x4_bitboard_cube.cube_face[BACK_INDEX] & BITMASK_CUBE_FACE_ROW_01);
/*********************************************************************************/
/* Rotate the TOP */
/*********************************************************************************/
/* */
/* THESE CUBE LOCATIONS BECOME.... THESE CUBE LOCATIONS */
/* */
/* */
/*********************************/ /*********************************/
/* 01 * 02 * 03 * 04 */ /* 04 * 08 * 12 * 16 */
/*********************************/ /*********************************/
/* 05 * 06 * 07 * 08 */ /* 03 * 07 * 11 * 15 */
/*********************************/ /*********************************/
/* 09 * 10 * 11 * 12 */ /* 02 * 06 * 10 * 14 */
/*********************************/ /*********************************/
/* 13 * 14 * 15 * 16 */ /* 01 * 05 * 09 * 13 */
/*********************************/ /*********************************/
/* */
/* */
/*********************************************************************************/
new_bitboard_cube.cube_face[TOP_INDEX] = ((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_04) << 12) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_08) << 24) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_12) << 36) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_16) << 48) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_03) >> 8) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_07) << 4) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_11) << 16) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_15) << 28) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_02) >> 28) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_06) >> 16) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_10) >> 4) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_14) << 8) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_01) >> 48) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_05) >> 36) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_09) >> 24) |\
((original_4x4x4_bitboard_cube.cube_face[TOP_INDEX] & BITMASK_CUBE_FACE_SQUARE_13) >> 12);
return new_bitboard_cube;
}
You can see the 32 instructions in the array generator have been reduced to 5 instructions in the bitboard implementation.
The bitboard also makes use of these bit patterns...
Code:
#define BITMASK_CUBE_FACE_SQUARE_01 0xF000000000000000
#define BITMASK_CUBE_FACE_SQUARE_02 0x0F00000000000000
#define BITMASK_CUBE_FACE_SQUARE_03 0x00F0000000000000
#define BITMASK_CUBE_FACE_SQUARE_04 0x000F000000000000
#define BITMASK_CUBE_FACE_SQUARE_05 0x0000F00000000000
#define BITMASK_CUBE_FACE_SQUARE_06 0x00000F0000000000
#define BITMASK_CUBE_FACE_SQUARE_07 0x000000F000000000
#define BITMASK_CUBE_FACE_SQUARE_08 0x0000000F00000000
#define BITMASK_CUBE_FACE_SQUARE_09 0x00000000F0000000
#define BITMASK_CUBE_FACE_SQUARE_10 0x000000000F000000
#define BITMASK_CUBE_FACE_SQUARE_11 0x0000000000F00000
#define BITMASK_CUBE_FACE_SQUARE_12 0x00000000000F0000
#define BITMASK_CUBE_FACE_SQUARE_13 0x000000000000F000
#define BITMASK_CUBE_FACE_SQUARE_14 0x0000000000000F00
#define BITMASK_CUBE_FACE_SQUARE_15 0x00000000000000F0
#define BITMASK_CUBE_FACE_SQUARE_16 0x000000000000000F
#define BITMASK_CUBE_FACE_ROW_01 0xFFFF000000000000
#define BITMASK_CUBE_FACE_ROW_02 0x0000FFFF00000000
#define BITMASK_CUBE_FACE_ROW_03 0x00000000FFFF0000
#define BITMASK_CUBE_FACE_ROW_04 0x000000000000FFFF
#define BITMASK_CUBE_FACE_NOT_ROW_01 0x0000FFFFFFFFFFFF
#define BITMASK_CUBE_FACE_NOT_ROW_02 0xFFFF0000FFFFFFFF
#define BITMASK_CUBE_FACE_NOT_ROW_03 0xFFFFFFFF0000FFFF
#define BITMASK_CUBE_FACE_NOT_ROW_04 0xFFFFFFFFFFFF0000
And in other news, I am happy to report that the 4-TFS database is now working. The program solved a swap of 2 centers after a nominal depth of 4 ply
The program only searched 90,188 nodes to find it.
Last edited by a moderator:
