This is a adaptation of my project Arduino Mega Chess
https://create.arduino.cc/projecthub/Sergey_Urusov/arduino-mega-chess-d54383
for ESP32 M5Stack. GUI was redone almost completely to use 3 buttons interface and small 2 inch screen.
Advantages of M5Stack platform are repeatability and solving power of ESP32. In comparison with original project performance level grows up in about 15 times, and is 2000-5000 nodes per second, what lead up to 10 plyes depth of solving tree in hard situations, and more in easy positions.
Engine was updated a little too, to give player list of possible moves sorted in decrease of usefulness, what ordinary alpha-beta algorithm can not give.
Interface uses 3 buttons - left, choice, and right. Left and right to choose move (highlighted with green frames), choice button to make move, long press of choice button (more then half of second press and release) to open menu, or close menu and return to game mode.
In menu you may take last move back, rotate chess board (opposite side plays M5Stack), open game menu to save game, load previously saved game, or download position from usb port in FEN format. Also there is a choise of game difficulty level, and sound may be turned on or off.
Before you can choose highlighted move, algorithm spends some time to form list of possible moves (up to 5-6 sec, may be little more), sorting them, so after appearing highlighted move pressing right button you choose steps in descending order of usefulness.
After your move and 3 seconds waiting algorithm starts thinking, answers, and all repeats. In waiting 3 sec time you may long press choice button to enter menu.
3 levels of difficulty differs in mean thinking time of algorithm - 4 sec (LOW), 15 sec (MEDIUM), 60 sec (HIGH). In hard situations this time may be exceeded about 2 times.
LOW level is not mean that algorithm will succumb, it plays better than me for example, but i do not have any chess rating, just amateur. Anyway level of engine does not comparable to modern chess engines due to absence 64 bits bitboards and hash, so i position this project as a toy only.
Thank you for interest to my projects, glad to see any comments, suggestions, found glitches etc.
EXPANDED TECHNICAL DETAILS
High-Performance Strategic AI
This project implements a fully functional Chess engine on the M5Stack (ESP32) platform, porting the famous "Arduino Mega Chess" logic to a more powerful core.
- Transposition Table Management: Leverages the ESP32's large RAM to store previously evaluated board states. This drastically speeds up the Minimax search algorithm (with Alpha-Beta pruning) by avoiding redundant calculations.
- TFT Touch Interface: The M5Stack's integrated color screen is used to render a high-resolution 2D board. The firmware maps touch-screen coordinates to chess algebraic notation (e.g., e2 to e4) for a professional user experience.
Performance
- ESP32 Dual-Core Execution: (Advanced version) The chess engine runs on one core while the UI and user input are handled on the second core, ensuring a responsive interface even during deep AI "Thinking" cycles.