@@ -353,6 +353,33 @@ void MainThread::search() {
353353 std::cout << sync_endl;
354354}
355355
356+ const int halfDensityMap[][9 ] =
357+ {
358+ {2 , 0 , 1 },
359+ {2 , 1 , 0 },
360+
361+ {4 , 0 , 0 , 1 , 1 },
362+ {4 , 0 , 1 , 1 , 0 },
363+ {4 , 1 , 1 , 0 , 0 },
364+ {4 , 1 , 0 , 0 , 1 },
365+
366+ {6 , 0 , 0 , 0 , 1 , 1 , 1 },
367+ {6 , 0 , 0 , 1 , 1 , 1 , 0 },
368+ {6 , 0 , 1 , 1 , 1 , 0 , 0 },
369+ {6 , 1 , 1 , 1 , 0 , 0 , 0 },
370+ {6 , 1 , 1 , 0 , 0 , 0 , 1 },
371+ {6 , 1 , 0 , 0 , 0 , 1 , 1 },
372+
373+ {8 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 },
374+ {8 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 0 },
375+ {8 , 0 , 0 , 1 , 1 , 1 , 1 , 0 ,0 },
376+ {8 , 0 , 1 , 1 , 1 , 1 , 0 , 0 ,0 },
377+ {8 , 1 , 1 , 1 , 1 , 0 , 0 , 0 ,0 },
378+ {8 , 1 , 1 , 1 , 0 , 0 , 0 , 0 ,1 },
379+ {8 , 1 , 1 , 0 , 0 , 0 , 0 , 1 ,1 },
380+ {8 , 1 , 0 , 0 , 0 , 0 , 1 , 1 ,1 },
381+ };
382+
356383
357384// Thread::search() is the main iterative deepening loop. It calls search()
358385// repeatedly with increasing depth until the allocated thinking time has been
@@ -394,27 +421,12 @@ void Thread::search() {
394421 while (++rootDepth < DEPTH_MAX && !Signals.stop && (!Limits.depth || rootDepth <= Limits.depth ))
395422 {
396423 // Set up the new depths for the helper threads skipping on average every
397- // 2nd ply (using a half-density map similar to a Hadamard matrix).
424+ // 2nd ply (using a half-density matrix).
398425 if (!mainThread)
399426 {
400- int d = rootDepth + rootPos.game_ply ();
401-
402- if (idx <= 6 || idx > 24 )
403- {
404- if (((d + idx) >> (msb (idx + 1 ) - 1 )) % 2 )
405- continue ;
406- }
407- else
408- {
409- // Table of values of 6 bits with 3 of them set
410- static const int HalfDensityMap[] = {
411- 0x07 , 0x0b , 0x0d , 0x0e , 0x13 , 0x16 , 0x19 , 0x1a , 0x1c ,
412- 0x23 , 0x25 , 0x26 , 0x29 , 0x2c , 0x31 , 0x32 , 0x34 , 0x38
413- };
414-
415- if ((HalfDensityMap[idx - 7 ] >> (d % 6 )) & 1 )
416- continue ;
417- }
427+ int row = (idx - 1 ) % 20 ;
428+ if (halfDensityMap[row][(rootDepth + rootPos.game_ply ()) % halfDensityMap[row][0 ] + 1 ])
429+ continue ;
418430 }
419431
420432 // Age out PV variability metric
0 commit comments