How does chess engines work ?

163 views

I know there’s different depths but I don’t know what any of it means.

In: 0

8 Answers

Anonymous 0 Comments

You mean the chess AIs?

They basically try moving every piece, look at what that might do, then iterate and check every possible move they can do from that new position, then every possible position from each of THOSE positions, etc….then do that again with the next piece.

Using this web of possible actions, it picks the most advantageous.

The more moves ahead it can look, the more processing power it needs, but the “better” it can play.

Anonymous 0 Comments

There are two types of advantage in chess, Material advantage and positional advantage. Material advantage is easy, that’s who has more pieces. Positional advantage is harder to quantify but it’s who has their pieces in better spots, controlling more of the board and having more pieces developed (able to freely move around the board and not stuck behind pawns). The computer looks for the move that increases both ther material and positional advantage the most. They will even look ahead a certain number of moves depending on the time constraints and power of the computer and create what is called a markov chain (which is a ELI5 on it’s own) that will measure the strength of a move into the future not just in the current board configuration.

Anonymous 0 Comments

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.

Anonymous 0 Comments

It’s better explain through a game of Tic-Tac-Toe.

So imagine a game of 3×3 TTT. You vs the Computer. The computer starts.

It has 9 possible moves. After each of these moves, it’s your turn, and you have 8 possible moves. After you played, the computer has 7 possibles moves, etc etc…

What a game computer does is list every one of those moves, until it reaches the end of the game. The end is either a draw, a computer win, or a computer loss.

Now assign a score to each state, based on how favorable it is to the computer. If it has 2 X and a Blank in a row, it’s very good, if you have to O and a Blank in a row, it’s bad. If on the next move it fills your Blank, it’s good. A win is VERY GOOD, a loss is VERY BAD.

So each state has a score assigned, and the computer will, at each move, try to maximize next step’s score, while taking into account that you will in turn try to maximize yours. This way, the computer plots an optimal path to a win.

For Tic Tac Toe it’s easy. There aren’t that many different states, and it’s easy to assign a score based on the state of the board.

For Chess it’s the same thing, except instead of plotting in advance every move up to the final state (we can’t store that much information), it will do so for the next *n* move (n being 2, 5, 10,… Chess masters can see so far as 5 moves in advance. Think of how amazing this is considering every possibility).

The main difficulty when creating those programs is finding what constitutes a good state and what’s a bad state.

Anonymous 0 Comments

Hi. I’ve been involved in chess engine testing since 1995. In simplistic terms human crafted engines use a hand made evaluation.

First determine the set of legal moves. Then a set of legal responses to each and so on. This grows into a problem so we trim lines that our evaluation say are losing.

Each line in the search tree returns a score. Highest score wins.

Piece values. Mobility. King safety. Pawn structure. Open or closed positions are are added to investigate each line.

Ai engines like alpha zero are completely different.

https://albillo.hpcalc.org/articles/Chess%20Tests%20VA012%20-%20The%20Never%20Concept%2081-82.pdf

My username here Epanek is the panek reference in this link

This is my live stream of chess engines including those using ai derived networks.

https://www.twitch.tv/edosani

Anonymous 0 Comments

Thank you to everyone who has supplied answers so far. I understand this type of approach discussed so far using an evaluation system. (check every legal move, evaluate every proprosed move for the value of the position – is it good or bad, and keep going, chasing good scoring lines).

But how do these new machine learning engines work? I read that AlphaZero taught itself? I guess I’m confused – wasn’t there some calculation that the sheer number of possible chess moves is an enormous number so how does that sort of system work?

Anonymous 0 Comments

Chess engines usually aren’t “calculating” every possible position all the time; we simply don’t have enough computing power for that.

Luckily, most chess games have little to no uniqueness, ie, this exact move sequence has happened before, sometimes many times before. The computer doesn’t really need to do any calculation, it can simply use what worked in the past. Only when the board gets unique does it need to start calculating moves with depth.

This is why chess engines playing each rarely get to determine their own opening, and a human actually chooses the first 2 or 3 moves of a chess match; it’s the only way to ensure the computers don’t choose the exact same move sequence every single game.

Anonymous 0 Comments

Traditional chess engines has 2 main functions in it.

The first is the evaluation. This is where you look at the board and you count all the pieces, king safety, passed pawns and all such things and give them a score.

Second is the calculation. Here the computer finds reasonable moves that makes sense and see how they do versus reasonable counter moves, and then reiterates with new possible moves and counter moves, all this goes into insane depth, something like 16-22 moves in advance. Here it becomes like a tree, one move gives opponent say 5 counter moves, for each countermove there’s 5 new moves, and those moves have countermoves, so the amount of calculation increases exponentially for each move you go deeper.

Because of the amount of possible moves and countermoves is very relevant to complexity, the chess engines are a lot stronger the more simplified the positions become.

For AI engines they are a lot different, it’s basically a blackbox of computation wizardry