[update] Documentation for heuristic, fork detection, and playable threats.
Updated Background information.md, Achtergrondinformatie.md, and README.md to describe the improved AI: playable vs non-playable threat scoring, fork detection bonus, and the split Phase 1 strategy. README now lists all three implementations and the AI strategy section. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,12 +114,36 @@ All configurable parameters are defined as `-D` flags in `platformio.ini`:
|
||||
| `WIFI_SSID` | `Connect4` | SSID for the WiFi access point |
|
||||
| `WIFI_PASSWORD` | `youlose4` | Password for the WiFi access point |
|
||||
|
||||
## AI Strategy
|
||||
|
||||
The AI uses **minimax with alpha-beta pruning** and a **heuristic evaluation function**. Moves are selected in three phases:
|
||||
|
||||
1. **Instant win/block** — scan all columns for an immediate win first, then for an opponent threat to block.
|
||||
2. **Blunder** (optional) — random move at a configurable chance, skipping the deep search.
|
||||
3. **Deep minimax search** — full tree search with alpha-beta pruning up to the configured ply depth.
|
||||
|
||||
The heuristic evaluates leaf nodes by scoring all 69 possible four-cell windows on the board:
|
||||
|
||||
- **Playable threats** (3-in-a-row where the gap can be filled now): ±100
|
||||
- **Non-playable threats** (gap is floating in the air): ±40
|
||||
- **Two-in-a-row setups**: ±5
|
||||
- **Center column control**: ±3 per piece
|
||||
- **Fork bonus** (2+ simultaneous three-in-a-row threats): ±200
|
||||
|
||||
See `Background information.md` / `Achtergrondinformatie.md` for a detailed explanation accessible to all ages.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
src/main.cpp Single-file application (all game logic, AI, LED, web server)
|
||||
platformio.ini Build configuration, pin mappings, and tunable parameters
|
||||
README.md This file - technical and practical information
|
||||
Background information.md How the AI works (suitable for all ages)
|
||||
CLAUDE.md AI assistant project context
|
||||
src/main.cpp ESP32 application (game logic, AI, LED, web server)
|
||||
connect_four.js JavaScript browser edition (canvas rendering)
|
||||
connect_four.html HTML wrapper for the JavaScript version
|
||||
connect_four.py Python terminal edition (Rich TUI)
|
||||
platformio.ini Build configuration, pin mappings, and tunable parameters
|
||||
README.md This file - technical and practical information
|
||||
Background information.md How the AI works (English, suitable for all ages)
|
||||
Achtergrondinformatie.md How the AI works (Dutch, suitable for all ages)
|
||||
CLAUDE.md AI assistant project context
|
||||
```
|
||||
|
||||
All three implementations (C++, JavaScript, Python) share the same AI algorithm and heuristic.
|
||||
|
||||
Reference in New Issue
Block a user