[update] Background information and add Dutch translation.

This commit is contained in:
2026-03-15 16:19:01 +01:00
parent f489442cb5
commit 7118738818
2 changed files with 167 additions and 8 deletions
+18 -8
View File
@@ -53,27 +53,37 @@ Imagine there are only 3 columns left and the AI can look 2 moves ahead. It buil
The AI compares -3, +2, and -1, and picks column 3 because +2 is the best it can guarantee.
### Scoring
### Scoring: How the AI Rates a Board
The AI assigns scores to board positions:
After playing out a "what if?" scenario, the AI needs to decide: is this a good result or a bad one? It uses a very simple scoring system with only three possible outcomes:
- **+1000 or more:** The AI wins. A faster win gets a higher score, so the AI goes for the quickest victory.
- **-1000 or less:** The opponent wins. A faster loss gets a more negative score, so the AI fights hardest against immediate threats.
- **0:** Nobody has won and the search depth ran out. The position is neutral.
- **+1000 or more: "I win!"** The AI found a way to get four in a row. The bonus points above 1000 depend on how quickly it can win. Winning in 2 moves scores higher than winning in 6 moves. This is why the AI always goes for the fastest victory — it never wastes time when it can finish the game.
This scoring is why the AI has "killer instinct" - it doesn't just try to win, it tries to win as fast as possible.
- **-1000 or less: "I lose!"** The opponent gets four in a row. Losing sooner gets an even worse score. This makes the AI fight hardest against moves that threaten an immediate loss.
- **0: "I don't know yet."** The AI looked as far ahead as it could (it ran out of plies) and nobody won. It simply calls this position "neutral" — not good, not bad.
That's it — the AI does not give extra points for having three in a row, controlling the center, or any other clever trick. It relies entirely on looking many moves ahead to figure out which moves lead to wins and which ones don't. If it can't see a win or loss within its search depth, every position looks the same.
### Why the center column matters
Even though the AI doesn't give bonus points for playing in the center, it always checks the center column first (column 3), then works outward (2, 4, 1, 5, 0, 6).
The center column is involved in more possible winning lines than the edges, so checking it first helps the AI find good moves faster and skip bad ones sooner (thanks to alpha-beta pruning).
## 4. Alpha-Beta Pruning: The Smart Shortcut
### The problem
Looking ahead 8 plies in Connect 4 means exploring millions of board positions. Even a fast microcontroller can't check them all in a reasonable time.
Looking ahead 8 plies in Connect 4 means exploring millions of board positions.
Even a fast microcontroller can't check them all in a reasonable time.
### The solution
**Alpha-Beta pruning** is a way to skip branches of the tree that can't possibly change the final decision.
Think of it like shopping for a birthday present. You visit Shop A and find a nice toy for 10 euros. Then you go to Shop B. The first item you see costs 15 euros, and you notice everything else in Shop B is even more expensive. You don't need to check every item in Shop B - you already know Shop A is better. You leave Shop B and save time.
Think of it like shopping for a birthday present. You visit Shop A and find a nice toy for 10 euros.
Then you go to Shop B. The first item you see costs 15 euros, and you notice everything else in Shop B is even more expensive.
You don't need to check every item in Shop B - you already know Shop A is better. You leave Shop B and save time.
The AI does the same thing: