Are you mobile, picoEngine?


With so many of my posts being about mobile phones, this title might seem misleading. However, I am not implying that picoEngine is on a mobile phone, but rather that I have added the ability for it to determine the mobility of the pieces on the board.

So far, picoEngine is off to a good start, since it now believes that the best first move you can make is that of e4, or the kings pawn to the fourth rank. This is great because it is taking into account the fact that such a move would allow it to be more active with it’s pieces. With one move it adds multiple options to it’s repertoire of available moves for the next turn. Here’s a look at the code:

	// Mobility evaluation
	string listMoves ="";
	int deltaChange = 0;
	try {
	listMoves = moveEvaluations.available(thatBoard, true, false, false);
		if (listMoves.size() == 0){
			deltaChange -= 10000; } else {
			deltaChange = deltaChange + listMoves.size()/5;
	listMoves = moveEvaluations.available(thatBoard, false, false, false);
		if (listMoves.size() == 0){
			deltaChange += 10000; } else {
			deltaChange = deltaChange - listMoves.size()/5;
	} catch (...) {
			cout << " Exception " << endl;
			} // End try/catch block
			//cout << deltaChange << " Delta " << endl;
	picoEval += deltaChange;

Pretty straight forward. Essentially, it checks both sides to see how many legal moves they are able to make, and adds a point for each white move, and minuses a point for each black move, creating a mobility delta. This delta, positive or negative, is added to the picoEval variable for final consideration. You can always check out the full commit if you’d like.

I wrapped it in a try/catch block to be safe, but I don’t think that I actually need it in this case. I may remove that later. The best part about this is the null move return. E.g., if no moves are returned, then the opponent must be in stalemate or check mate. This is highly desirable, and hopefully will allow picoEngine to choose moves that lead to a win. We’ll have to play it out and see.

Linux – keep it simple.

Single Ply Decisions from picoEngine!


While this may not seem like a real feat to many, I’m actually really excited about this. For the first time, picoEngine actually made an “informed decision” of what move to make. Granted, it is still making poor decisions, but they are at least no longer random.

Keeping in mind that the only evaluation criteria that I have given the engine is that of material difference, so currently, picoEngine is a hungry hungry hippo, because all it can do is attack any piece that comes within range. The downside to this is it will capture a pawn with it’s queen only to have you take back the queen with the defending pawn. So it is not a very bright engine, yet.

If I want to push it to the next level, there are several things I need to do. Currently, it is only searching 1 ply deep, meaning it checks each available move, and then picks the one move that gains the most points after it’s turn. In an ideal computer setup, you would want it to search multiple ply, as in what will it’s turn yield, and what will the evaluation read after the opponents turn. E.g., will they recapture the queen that you marched down there and stole their pawn with?

The commit is actually in two parts, and you are welcome to check them both out on my GitLab. One of the cool things about the current setup, is it does display the information in standard out, so you can actually see the decision being made first hand. The evaluation looks like this:

2019-02-19 13:40:13.611<–1:Move eval: f6g8 eval -10 places RNBQKBNRPPP–PPP———–Pn——————-pppppppprnbqkb-r
2019-02-19 13:40:13.611<–1:Move eval: f6e4 eval 0 places RNBQKBNRPPP–PPP———–PP—p————n—ppppppprnbqkb-r

Still needs some work, but definitely a step in the right direction!

Linux – keep it simple.

What’s your evaluation, picoEngine?


While certainly nothing fancy, I have added a quick material evaluation to picoEngine. Up till now, I’ve been using picoEngine with random moves on. It is an option that by default is off, but the end user can choose to play against the engine in random move mode, where the next move is chosen at random. By default it will now play in “Normal” mode, which tries to make an educated decision.

Of course, the engine does not have a brain, or any essence of being, and thus cannot really “choose” a move. Thus, by educated decision, I really mean a weighted decision. The simplest of all weights is that of material advantage. In this case, I’m using “deca-pawns”, where each pawn is worth 10 points, the nights 30, the bishops 30, the rook 50, the queen 100, and the king 1000 points, respectively.

I don’t intend for this to be the final say in making the decision for picoEngine. At this time, though, I’m really in a position to work out the details of making a decisive move, but to be able to “choose” the best move, it needs some criteria to choose from. Thus, I put in the smallest and simplest criteria I could think of so I could work on the real part of determining how picoEngine will cycle through the available moves in order to pick one to play.

Other good methods of evaluating the board are:

  • Space – how much area you control.
  • Development – leading or lacking thereof.
  • Mobility – the freedom of movement that your pieces enjoy verses your opponent.
  • Aggression – the ability to attack your opponent.
  • Defense – things like the status of castling, or if your pieces are defended from loss.

And of course, materialism, which is the simplest to implement, as it is basically a count of remaining pieces. The problem with materialism as a goal is that such a machine can be easily tricked with things like a queen sacrifice, but it is a start!

Linux – keep it simple.