picoEngine?! Where is the king?!

picoengineKingStuck

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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s