Chess engines are very complicated and can be built in many different ways. But the traditional way to make a chess engine is to start with a formula to evaluate a chess position. You may have been taught counting the material points on the board, pawns are worth 1 point, pieces 3, rooks 5 and the queen is worth 9 points. The chess engines use this, but also adds or subtract points for various other aspects of the position. Things like control over the centre, passed pawns, piece activity, king safety, etc. So the score they give a position is more accurate then just the material count.
But this is not enough to spot tactics. To do this they start by visualising all the legal moves they can make. For each one they calculate what the score would be after the move. Then they take some of the best moves for their opponent and visualise them. They calculate the scores again and then take some of their best moves. This goes on for a certain depth, always taking a number of best possible moves from the previous position. Eventually the engine have to decide and so it picks the line that would be best for it and make that move.
Latest Answers