ShowThinkingEvent(); // [HGM] thinking: make sure post/nopost state is set according to options\r
\r
GetTimeMark(&programStartTime);\r
+ srand(programStartTime.ms); // [HGM] book: makes sure random is unpredictabe to msec level\r
\r
ClearProgramStats();\r
programStats.ok_to_send = 1;\r
}\r
}\r
\r
-#if 0\r
-/* [AS] FRC game initialization */\r
-static int FindEmptySquare( Board board, int n )\r
-{\r
- int i = 0;\r
-\r
- while( 1 ) {\r
- while( board[0][i] != EmptySquare ) i++;\r
- if( n == 0 )\r
- break;\r
- n--;\r
- i++;\r
- }\r
-\r
- return i;\r
-}\r
-\r
-static void ShuffleFRC( Board board )\r
-{\r
- int i;\r
-\r
- srand( time(0) );\r
- \r
- for( i=0; i<8; i++ ) {\r
- board[0][i] = EmptySquare;\r
- }\r
-\r
- board[0][(rand() % 4)*2 ] = WhiteBishop; /* On dark square */\r
- board[0][(rand() % 4)*2+1] = WhiteBishop; /* On lite square */\r
- board[0][FindEmptySquare(board, rand() % 6)] = WhiteQueen;\r
- board[0][FindEmptySquare(board, rand() % 5)] = WhiteKnight;\r
- board[0][FindEmptySquare(board, rand() % 4)] = WhiteKnight;\r
- board[0][ i=FindEmptySquare(board, 0) ] = WhiteRook;\r
- initialRights[1] = initialRights[4] =\r
- castlingRights[0][1] = castlingRights[0][4] = i;\r
- board[0][ i=FindEmptySquare(board, 0) ] = WhiteKing;\r
- initialRights[2] = initialRights[5] =\r
- castlingRights[0][2] = castlingRights[0][5] = i;\r
- board[0][ i=FindEmptySquare(board, 0) ] = WhiteRook;\r
- initialRights[0] = initialRights[3] =\r
- castlingRights[0][0] = castlingRights[0][3] = i;\r
-\r
- for( i=BOARD_LEFT; i<BOARD_RGHT; i++ ) {\r
- board[BOARD_HEIGHT-1][i] = board[0][i] + BlackPawn - WhitePawn;\r
- }\r
-}\r
-\r
-static unsigned char FRC_KnightTable[10] = {\r
- 0x00, 0x01, 0x02, 0x03, 0x11, 0x12, 0x13, 0x22, 0x23, 0x33\r
-};\r
-\r
-static void SetupFRC( Board board, int pos_index )\r
-{\r
- int i;\r
- unsigned char knights;\r
-\r
- /* Bring the position index into a safe range (just in case...) */\r
- if( pos_index < 0 ) pos_index = 0;\r
-\r
- pos_index %= 960;\r
-\r
- /* Clear the board */\r
- for( i=0; i<8; i++ ) {\r
- board[0][i] = EmptySquare;\r
- }\r
-\r
- /* Place bishops and queen */\r
- board[0][ (pos_index % 4)*2 + 1 ] = WhiteBishop; /* On lite square */\r
- pos_index /= 4;\r
- \r
- board[0][ (pos_index % 4)*2 ] = WhiteBishop; /* On dark square */\r
- pos_index /= 4;\r
-\r
- board[0][ FindEmptySquare(board, pos_index % 6) ] = WhiteQueen;\r
- pos_index /= 6;\r
-\r
- /* Place knigths */\r
- knights = FRC_KnightTable[ pos_index ];\r
-\r
- board[0][ FindEmptySquare(board, knights / 16) ] = WhiteKnight;\r
- board[0][ FindEmptySquare(board, knights % 16) ] = WhiteKnight;\r
-\r
- /* Place rooks and king */\r
- board[0][ i=FindEmptySquare(board, 0) ] = WhiteRook;\r
- initialRights[1] = initialRights[4] =\r
- castlingRights[0][1] = castlingRights[0][4] = i;\r
- board[0][ i=FindEmptySquare(board, 0) ] = WhiteKing;\r
- initialRights[2] = initialRights[5] =\r
- castlingRights[0][2] = castlingRights[0][5] = i;\r
- board[0][ i=FindEmptySquare(board, 0) ] = WhiteRook;\r
- initialRights[0] = initialRights[3] =\r
- castlingRights[0][0] = castlingRights[0][3] = i;\r
-\r
- /* Mirror piece placement for black */\r
- for( i=BOARD_LEFT; i<BOARD_RGHT; i++ ) {\r
- board[BOARD_HEIGHT-1][i] = board[0][i] + BlackPawn - WhitePawn;\r
- }\r
-}\r
-#else\r
-// [HGM] shuffle: a more general way to suffle opening setups, applicable to arbitrry variants.\r
+// [HGM] shuffle: a general way to suffle opening setups, applicable to arbitrary variants.\r
// All positions will have equal probability, but the current method will not provide a unique\r
// numbering scheme for arrays that contain 3 or more pieces of the same kind.\r
#define DARK 1\r
\r
int squaresLeft[4];\r
int piecesLeft[(int)BlackPawn];\r
-u64 seed, nrOfShuffles;\r
+int seed, nrOfShuffles;\r
\r
void GetPositionNumber()\r
{ // sets global variable seed\r
\r
seed = appData.defaultFrcPosition;\r
if(seed < 0) { // randomize based on time for negative FRC position numbers\r
- srandom(time(0)); \r
for(i=0; i<50; i++) seed += random();\r
seed = random() ^ random() >> 8 ^ random() << 8;\r
if(seed<0) seed = -seed;\r
if(number >= 0) appData.defaultFrcPosition %= nrOfShuffles; // normalize\r
}\r
\r
-#endif\r
-\r
int SetCharTable( char *table, const char * map )\r
/* [HGM] moved here from winboard.c because of its general usefulness */\r
/* Basically a safe strcpy that uses the last character as King */\r