กลับไปหน้ารวมไฟล์
try-to-win-against-this-othello-game-c4b71f-en.md

The Othello game is a strategy board game like chess or checkers. The rules are very simple: the two players put down alternately black and white disks on the board. When you put down a disk of your own color, you must trap one or more opponent's disks between the new disk and an existing one of your own color. The trapped disks become yours and take your own color. The object is to have as many disks as possible at the end of the game.

If you want more details about the Othello's rules, you can easily find them on the Web, or you can learn them experimentally by playing with this program.

The game was named Othello in reference to Shakespeare's well known play. I named my program Athalie in reference to the famous French playwriter Racine's play.

The main characteristics of Athalie are:

- seven game levels,

- two user interfaces that can be used either independently or simultaneously,

- a replay mode allowing you to change a move or the game level, to reverse the roles or to review the game,

- two players mode,

- display of allowed squares when it is player's turn,

- stopwatches for the two competitors (only on OLED display).

Main menu

The game

Othello is a well-known game. It has its own federation and its own championships. It has the rare particularity that some programs can beat the best human players because of the difficulty in imagining the state of the board after several moves. Athalie is far from this level, but it can help you to progress to a fairly good level.

If you are a beginner, here are the two main tips to follow to improve your strategy:

- try to limit your opponent's possible moves and increase yours. To do so, it is a good idea to limit the number of your disks, except at the end of the game,

- try to occupy the corner squares.

Hardware

The program runs on an Arduino Nano Every board. It provides two user interfaces. The first one is through the serial monitor of the IDE. If you only use this interface, you don't need any hardware except the Nano Every board and a cable to connect it to your PC.

You can play just with an Arduino Nano Every board and the Serial monitor

The second user interface uses an OLED display and six push buttons, and it allows the game to be self-contained.

The OLED display is a 128x64 pixel monochrome one. A level translator is needed to adapt the logic levels of the Nano Every (5V) to those of the display (3.3V). The OLED display is controlled by an I2C interface.

Two large push buttons (12 mm) are used for both Menu and Enter commands. Four small push buttons (6 mm) are placed to be used as four directions arrows, like a joystick.

Signal-Swing & Logical-Level Forensics

Level-Translator Analytics: The Nano Every operates at 5V, while the OLED requires 3.3V. This necessitates a 4-channel level translator to manage logic-thresholds and ensure signal fidelity. The diagnostics ensure that high-frequency I2C edges maintain integrity without inducing logical-ghosting or signal degradation.

Input-Directional Heuristics: The 4-button joystick-emulation array is used for navigation. Forensics focus on "Directional-Vector Diagnostics," ensuring the cursor-logic maps correctly to the board-coordinates for precise user input.

Software

The software uses two libraries that you can install with the library manager:

- u8g2 by Oliver to control the OLED display. You have to adapt the line #19 of the program to your own display, particularly to the display controller: SH1106, SSD1306...

- TimerInterrupt_Generic by Khoi Hoang to control the players' stopwatches.

If you are only using the serial monitor as a user interface, you do not need to install those libraries, provided that you comment or suppress the line #15 of the program (#define OLEDDisplay). If you do so, the program does not control the OLED display and the push buttons any longer. The game features are exactly the same except for the stopwatches which disappear. The compilation and the uploading are much faster.

It is not really essential to explain how the program handles the game and the user interfaces. It seems to me more important to explain how Athalie finds the best move when it is its turn to play. Four elements contribute to this search: an opening book, an evaluation function, a mini-max algorithm and an alpha-beta algorithm.

HMI-Matrix & Visual-State Diagnostics

The OLED-Raster Probe: Spatial game-states are rendered on the 128x64 monochrome display. This involves managing I2C-packet latency during high-density board updates to ensure a smooth visual experience.

Interrupt-Driven Stopwatch Analytics: Utilizing the `TimerInterrupt` library maintains sub-millisecond game-clock forensics for both players. The diagnostics ensure that intensive CPU-calculations in the logic-engine don't induce temporal-drift harmonics in the user stopwatches, keeping timekeeping accurate.

Opening Book

The program knows several series of often played moves at the start of a game, and it plays these moves mechanically until it encounters an unknown move in the series. These series are noted in the program as strings such as "C4C3D3C5D6F4F5", and they are easy to modify or complete. During this phase, the program is very fast.

Evaluation Function & Strategy Forensics

The evaluation function is a cooking recipe that attempts to evaluate a static position of the game. Each programmer has his own recipe. Mine uses several criteria such as the mobility of each player, the edges with five disks of the same color, a value attributed to each square etc... These criteria are mixed with coefficients varying according to the total number of disks, i. e. the progress of the game. The result is a score. The greater this score is, the more the position is judged in favor of the white player.

The engine utilizes a complex evaluation-formula based on mobility, edge-control, and corner-dominance. Forensics involve the tuning of "Strategy-Coefficients" (e.g., weighing corners at 10x mobility). The diagnostics utilize a "Self-Play" routine, which I implemented by making Athalie play against itself on two Arduino boards communicating through the SoftwareSerial library, to optimize the strategy-forensics.

Mini-Max Algorithm: The Decision-Logic Orchestration

From a position, we try all the possible moves for the player whose turn it is. Then we try all the possible answers from the other player. And so on until we reach the depth defined by the game level. At the end of this process, we use the evaluation function to give a score to the obtained position and we send this score to the upper level where it is compared with the scores of the other moves to choose the best one.

To do that we use a recursive function (which I named bestMove), i. e. it calls itself as many times as there are levels to browse. This brings some constraints especially about the amount of RAM used (at each level we have to make a copy of the board) and the use of global variables.

The system implements a recursive decision-matrix. At higher levels (7+), the engine evaluates thousands of potential board-states. The diagnostics focus on "RAM-Partitioning Analytics," ensuring that recursive-function stacks don't induce heap-collision diagnostics or memory overflow.

Alpha-Beta Algorithm: Pruning Harmonics

The mini-max algorithm may be very time consuming, especially when the game level is high. The alpha-beta algorithm is a powerful mean to speed up the mini-max algorithm. Imagine you have tried some moves and found a correct score for at least one of them. Then you try an other move and you see that your opponent can answer with a move that kills you. Do you find it useful to evaluate your opponent's other answers ? Of course not. Do not waste your time evaluating answers to a move that will not be played. This is called pruning, we prune a branch of the tree that we are browsing.

For a better efficiency of the alpha-beta algorithm, it is important to evaluate the best moves first. So, before browsing the tree, we evaluate the positions obtained by all the possible moves from a position, and we sort them according to their scores.

To accelerate execution, the firmware utilizes alpha-beta pruning. Forensics involve the deterministic "Cutting" of sub-trees that cannot improve the current node's value. The diagnostics focus on "Pruning-Efficiency Analytics," which can significantly reduce the search complexity from O(b^d) to approximately O(b^(d/2)), where b is the branching factor and d is the depth.

Conclusion

If you are interested in this program, you now have some keys to understand how it works. But even if you don't try to disassemble the engine, you might enjoy progressing in Othello game and having fun playing with Athalie. I would be pleased if you posted some comments to tell me at what level you can beat Athalie.

This project represents a rigorous implementation of deterministic game-logic and asynchronous minimax orchestration on the Arduino Nano Every. By mastering minimax forensics and alpha-beta pruning, it delivers a robust, professional-grade gaming platform that provides clear strategic depth through sophisticated decision-tree diagnostics.

Logic Persistence: Mastering strategy telemetry through minimax forensics.

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "Arduino IDE Serial Monitor"
author: "frenchy22"
category: "Gadgets, Games & Toys"
components:
  - "1x Arduino Nano Every (Logic Engine Hub)"
  - "1x 1.3\" OLED Display I2C (HMI Matrix Node)"
  - "1x Level Translator (Logic-Swing Forensics)"
  - "2x 12mm Pushbuttons (Menu/Enter Nodes)"
  - "4x 6mm Pushbuttons (Directional-Input Array)"
description: "A professional-level strategic-gaming engine featuring deterministic minimax-logic, alpha-beta pruning diagnostics, and OLED-based HMI game-state forensics."
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles:
  - "https://projects.arduinocontent.cc/3f43e722-01d7-4aba-a699-abef337a61a4.ino"
encryptedPayload: "U2FsdGVkX1/HfZXn9Iq24djns9IBLiQJ7+IzwNYOTMAirWvuj3yknUJ9XtI7pJBjCj8KAP/iYlfnW5wbCxuwRvEdaWy/C2HeMu9gMvZQFyU="
heroImage: "https://raw.githubusercontent.com/bigboxthailand/arduino-assets/main/images/projects/try-to-win-against-this-othello-game-c4b71f_content_1.jpg"
lang: "en"
likes: 2344
passwordHash: "29f75336e99623d5ea5e450d0cb41200d6ccacce6ead4aabc0b2c49e0a49b141"
price: 299
seoDescription: "Test your skills against this Othello game on Arduino. Features multiple levels to help you become a champion."
tags:
  - "minimax-algorithm-forensics"
  - "alpha-beta-pruning-diagnostics"
  - "game-logic-heuristics"
  - "strategic-gaming-harmonics"
  - "arduino-nano-every"
title: "Othello-Bot: Minimax-Algorithm Forensics & Alpha-Beta Pruning Harmonics"
tools:
  - "u8g2 (OLED-Raster Orchestration)"
  - "TimerInterrupt_Generic (Temporal-Constraint Diagnostics)"
videoLinks: []
views: 2344