What good is king safety if the king refuses to capture it’s attacker? I guess I had programmed a cowardly lion… er… uh… king. Actually the real problem was that of where the king “was” on the board, per my code.

  // For checking if the king is safe.

int z;

if (whoseTurn){

for (int i = 0; i < 64; i++) {

switch (boardPositions[i]) {

–  case ‘K’: z = boardPositions[i];break;

+  case ‘K’: z = i;break;



So rather than the king being where he was supposed to be, the engine believed the king to be off the board at square “75” (it is the integer equivalent of the character ‘k’). So, above, you can see the minus of “case ‘K’: z = boardPositions[i];break;” and the plus replacing it with “case ‘K’: z = i;break;”. We needed it’s integer position on the board, not the integer equivalent of the character ‘k’…. Sometimes I marvel at my own foolishness.

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *