Don't understand minimax algorithm in terms of chess

I'm new to minimax algorithm, but i understand it's entire concepts as it's easy, my biggest issue is understanding it's implementation to my chess game, no internet solution answers this question

black or white players comprises of several pieces, so what piece is the AI predicting moves for, as the player could move any of their 16 pieces?

all i keep seeing is that we need to write the code to look several moves ahead in which the player could potentially make, my issue is that there are multiple pieces the player could pick from so what moves exactly are we talking about and how would the AI determine which of its pieces to move based on that.

I just need a brief explanation, no source code or how to's. I've spent days trying to wrap my head around this concept.

• The "AI" is you writing code. – gnasher729 May 5 at 10:50
• You should do more research first. Before understanding how to apply minimax to chess it's probably best to first understand how minimax works. Here is a link to Minimax. You may be interested in the "zero-sum games" section as that is what chess is. Here is an article on minimax for chess. If you're wondering about the difference between game state and game board, this answer may help. – ryan May 5 at 21:45

In minimax you fully explore the game tree. So the answer to "which piece" is all of them. All possible moves for all movable pieces. And then it selects the minimum or maximum (depending on the depth) out of those options.

Obviously this isn't feasible which is why we never apply raw minimax to chess. It is always with other optimizations such as alpha-beta, and stopping after a certain depth and using a heuristic evaluation of that position instead of continuing.

You write a function that looks at a position and gives it a value. The value should be higher for good positions and lower for bad positions.

Strategy 1: You try all your possible moves, evaluate the position after each move, and pick the move that produces the highest value.

Strategy 2: You try all your possible moves, then assume that the opponent will move according to Strategy 1. You pick the move that produces the highest value after the opponent moved according to Strategy 1.

Strategy 3: You try all your possible moves, then assume that the opponent will move according to Strategy 2. You pick the move that produces the highest value after the opponent moved according to Strategy 2.

Your guess is what strategies 4, 5, 6 and 7 are :-) Of course each strategy is more time consuming than the previous one, so you stop when you run out of time. And there are a few tricks to make the evaluation faster.