@@ -290,24 +290,10 @@ int16 Game::alphabeta(HexaBitBoardPosition *pos, uint64 hash, int depth, int cur
290290 // update killer move table if this was a non-capture move
291291 if (!(ttMove.getFlags () & CM_FLAG_CAPTURE))
292292 {
293- // TODO: add to the first slot
294-
295- bool foundKiller = false ;
296- for (int j = 0 ; j < MAX_KILLERS; j++)
293+ if (killers[depth][0 ] != ttMove)
297294 {
298- if (killers[depth][j] == ttMove)
299- {
300- foundKiller = true ;
301- break ;
302- }
303- }
304-
305- if (!foundKiller)
306- {
307- for (int j = 1 ; j < MAX_KILLERS; j++)
308- killers[depth][j] = killers[depth][j - 1 ];
295+ killers[depth][1 ] = killers[depth][0 ];
309296 killers[depth][0 ] = ttMove;
310-
311297 }
312298 }
313299
@@ -390,7 +376,9 @@ int16 Game::alphabeta(HexaBitBoardPosition *pos, uint64 hash, int depth, int cur
390376 }
391377
392378 // try killers first
393- // also filter out killers and TT move from the list
379+ // also filter out killers and TT move from the list
380+ // TODO: no need to generate non captures if we get a cutoff on trying killer moves
381+ // need a move validity checker routine
394382 for (int i = searched; i < nMoves; i++)
395383 {
396384 // filter TT moves
@@ -399,16 +387,9 @@ int16 Game::alphabeta(HexaBitBoardPosition *pos, uint64 hash, int depth, int cur
399387 newMoves[i] = CMove ();
400388 continue ;
401389 }
402- bool isKiller = false ;
403390
404- for (int j = 0 ; j < MAX_KILLERS; j++)
405- {
406- if (killers[depth][j] == newMoves[i])
407- {
408- isKiller = true ;
409- break ;
410- }
411- }
391+ bool isKiller = (killers[depth][0 ] == newMoves[i]) ||
392+ (killers[depth][1 ] == newMoves[i]);
412393
413394 if (isKiller)
414395 {
@@ -419,7 +400,13 @@ int16 Game::alphabeta(HexaBitBoardPosition *pos, uint64 hash, int depth, int cur
419400 int16 curScore = -alphabeta<!chance>(&newPos, newHash, depth - 1 , curPly + 1 , -beta, -alpha, true );
420401 if (curScore >= beta)
421402 {
422- // TODO: increase priority of this killer
403+ // increase priority of this killer
404+ if (killers[depth][0 ] != newMoves[i])
405+ {
406+ killers[depth][1 ] = killers[depth][0 ];
407+ killers[depth][0 ] = newMoves[i];
408+ }
409+
423410 TranspositionTable::update (hash, curScore, SCORE_GE, newMoves[i], depth, curPly);
424411 return curScore;
425412 }
@@ -454,8 +441,7 @@ int16 Game::alphabeta(HexaBitBoardPosition *pos, uint64 hash, int depth, int cur
454441 if (curScore >= beta)
455442 {
456443 // update killer table
457- for (int j = 1 ; j < MAX_KILLERS; j++)
458- killers[depth][j] = killers[depth][j - 1 ];
444+ killers[depth][1 ] = killers[depth][0 ];
459445 killers[depth][0 ] = newMoves[i];
460446
461447 TranspositionTable::update (hash, curScore, SCORE_GE, newMoves[i], depth, curPly);
0 commit comments