picoEngineMoves

For the first time ever, picoEngine made it’s very own move.

While no where near as important as my children taking their first steps, it was really a monumental moment for me when picoEngine made it’s very first move using UCI commands while loaded in Arena. That’s right, after several hours of tinkering, I loaded the picoEngine into the chess application called Arena, and let it make it’s very first move!

Of course, at this point, the only thing it can move is the knight, since that’s all I’ve programmed it for, but still, it was a monumental step in the direction of C++ chess engine programming for me!

While I’ve made two chess engines in Java, for various Android apps, this is different. Not only am I programming in C++, but my goal is to use the Universal Chess Interface so my chess engine can be loaded into any chess program. That is making things a bit tough. But now that I have successfully made a move, hopefully it will be smooth sailing from here on out.

string Moves::bestMove(string boardPositions, bool whoseTurn, bool styleRandom){
string candidateList = Moves::available(boardPositions, whoseTurn);
string chosenMove = “”;
if (candidateList.size() > 0){
//if (styleRandom) {
srand((int)time(0) + candidateList.size());
int r = (rand() % (candidateList.size()/5));
for (int a = 0; a < 4; a++) {
chosenMove += candidateList[(5*r)+a];
}
//} else {

//}
}
return chosenMove;
}

The check for available moves and king safety are things we already covered, so essentially, I just needed to make it choose the best move of the ones available. In the future, this will hopefully be a weighted decision, but for now, I’m just passing a random choice of the available moves in the list, which, of course, only features the knights at present.

As always, you can check out the full commit on my GitLab.

Linux – keep it simple.

Leave a Reply

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