MeArm Robotic Arm Plays Tic-Tac-Toe: Vision Recognition + Decision Algorithm + Mechanical Control in Practice

MeArm robotic arm plays Tic-Tac-Toe using computer vision, Minimax algorithm, and inverse kinematics.
A maker project demonstrates a MeArm robotic arm playing Tic-Tac-Toe against humans by integrating three core modules: OpenCV-based vision recognition for reading the board, Minimax algorithm for unbeatable decision-making, and inverse kinematics for precise mechanical control. Though simple, the project fully implements the perception-planning-actuation loop fundamental to all autonomous robotic systems.
When a Robotic Arm Learns to Play Tic-Tac-Toe
In the open-source robotics world, MeArm has long been one of the most popular platforms for beginners — simple in structure, low in cost, yet capable of surprisingly impressive motion control tasks. MeArm was initiated by British engineer Ben Gray in 2014, originally funded through a Kickstarter campaign. It uses laser-cut acrylic or wooden panels as structural components, driven by four micro servos (typically SG90 or MG90S) that control base rotation, shoulder joint, elbow joint, and end-effector gripper respectively. The total hardware cost usually ranges between $20–50, and it can be driven by mainstream development boards such as Arduino, Raspberry Pi, or micro:bit. The design files are open-sourced under a Creative Commons license, allowing anyone to freely download, modify, and manufacture it — making it one of the most popular entry-level robotic arm platforms in the global maker community.
Recently, a maker shared a rather fun project: having a MeArm robotic arm play Tic-Tac-Toe against a human opponent.
This project is far more than a simple mechanical motion demo — it integrates computer vision, decision algorithms, and mechanical control into a complete interactive robotic system. The robotic arm uses a camera to identify where a human has placed their mark on a paper board, computes its own strategy, and then uses a pen to draw its move on the board.

System Architecture Breakdown: Three Core Modules
From a structural perspective, the entire system can be broken down into three core components, each representing a classic challenge in embedded robotics development.
Vision Recognition: Teaching the Machine to "Read" the Board with OpenCV
The system uses a webcam to monitor a paper game board placed on a tabletop in real time. The technical challenge here is: how to accurately identify the state of each cell in the 3×3 grid — whether it's empty, contains a circle drawn by the human, or a cross drawn by the robotic arm — under varying lighting conditions, paper tilt, and inconsistent pen strokes.
This type of recognition relies on OpenCV (Open Source Computer Vision Library), an open-source computer vision and machine learning library initiated by Intel in 1999 and currently maintained by the non-profit organization OpenCV.org. It contains over 2,500 optimized algorithms covering image processing, feature detection, object tracking, camera calibration, and more, with support for multiple programming languages including C++, Python, and Java. In embedded vision projects, OpenCV is commonly deployed on single-board computers like Raspberry Pi, paired with USB cameras for real-time image analysis.
Specifically in this project, the system uses image preprocessing (grayscale conversion, binarization, perspective correction) to locate the board boundaries, then classifies the content of each cell. The Perspective Transform function is particularly critical — it can rectify a board image captured at an angle into a top-down view, simplifying subsequent cell localization and content recognition. Compared to industrial-grade vision systems, recognizing hand-drawn marks on paper demands greater algorithm robustness, since human handwriting is often irregular — circles may not be round, crosses may not be symmetrical — all of which require the classification algorithm to have sufficient fault tolerance.
Decision Logic: Unbeatable Strategy with the Minimax Algorithm
Tic-Tac-Toe is a fully solved game. When both sides play optimally, the game inevitably ends in a draw. Therefore, the robotic arm's decision module can employ the classic Minimax algorithm, further optimized with Alpha-Beta pruning to improve search efficiency.
The Minimax algorithm originates from game theory, with its mathematical foundation laid by John von Neumann's minimax theorem in 1928. The algorithm constructs a complete game tree, alternately simulating both players' optimal decisions — one side tries to maximize its own payoff (Max layer), while the other tries to minimize the opponent's payoff (Min layer), ultimately backtracking to determine the best move for the current position. Alpha-Beta pruning is an important optimization of Minimax that skips branches during the search that cannot possibly affect the final decision, reducing the number of search nodes from O(b^d) to O(b^(d/2)) in the best case, where b is the branching factor and d is the search depth.
For a game like Tic-Tac-Toe with an extremely small state space — the complete game tree contains only about 255,168 possible game sequences (approximately 26,830 unique board states after deduplication) — even exhaustively enumerating all possible move combinations is well within the processing capability of a microcontroller or Raspberry Pi. Even 8-bit microcontrollers can complete a full tree search in milliseconds. This means developers can make the robotic arm "never lose" — it either wins or draws.
Mechanical Execution: Inverse Kinematics Translates Coordinates into Action
Once the optimal move position is identified, the system needs to convert the logical coordinates on the board into physical coordinates for the robotic arm's end effector. This involves Inverse Kinematics (IK) computation. Inverse kinematics is one of the core problems in robotics, the reverse process of Forward Kinematics: forward kinematics determines the end-effector position given joint angles, while inverse kinematics works backward from a target position to determine the required joint angles.
MeArm is a typical four-degree-of-freedom serial robotic arm. Common IK solving methods include the geometric approach (direct derivation using trigonometric functions) and numerical iteration methods (such as the Jacobian matrix method). A four-DOF robotic arm has a limited workspace in three-dimensional space, with its reachable workspace forming an irregular annular region — the game board needs to be placed within this effective range. Additionally, a calibration process is required to establish precise mapping between the board's logical coordinates and the arm's joint space. Controlling the MeArm to draw a clean "O" or "X" requires precise coordination of multiple servo angles.
The key challenge in this stage is precision control. Micro servos like the SG90 control angle via PWM (Pulse Width Modulation) signals, with typical control accuracy of about 1–2 degrees, but actual performance is affected by gear backlash, load variations, and power supply voltage fluctuations. Cheap servos can exhibit idle jitter of up to ±1 degree, and due to the linkage amplification effect in MeArm, the end-effector positioning error can reach several millimeters. Common improvements include: using higher-precision digital servos, adding software-level PID compensation, and averaging multiple samples at critical positions. The contact pressure between the pen tip and paper also needs careful tuning — typically achieved by adjusting the Z-axis (vertical) press depth, with some advanced designs incorporating force sensors or compliant mechanisms for passive compliance. Too light and no mark is made; too heavy and it may damage the pen or jam the arm.
Why This Kind of Robotics Project Matters
On the surface, a Tic-Tac-Toe-playing robot might seem like a mere "toy-level" project, but its value lies precisely in being small but complete — a sparrow may be tiny, but it has all the vital organs.
It fully covers the core closed loop of an autonomous robotic system: Perception → Planning → Actuation. This "perception-planning-actuation" architecture is the classic three-layer robot control paradigm, extensively discussed in the 1980s research of Rodney Brooks and others, and remains the foundational framework for understanding robotic systems to this day. In modern complex systems, this loop is further refined: the perception layer fuses data from multiple sensors (vision, LiDAR, IMU, etc.) to build an environment model; the planning layer performs path planning and task planning on this model; and the actuation layer converts planning results into physical actions through motor controllers.
This is the fundamental architecture shared by everything from robot vacuums to self-driving cars. Taking autonomous driving as an example, the perception module corresponds to camera and LiDAR data fusion, the planning module corresponds to behavioral decision-making and trajectory planning, and the control module corresponds to lateral and longitudinal vehicle control. While the Tic-Tac-Toe robot is simple, it fully reproduces this architecture. For hobbyists learning robotics development, running through this entire pipeline in a controllable, low-cost scenario builds far more intuition than reading theoretical textbooks.
Furthermore, as open-source hardware, MeArm's CAD files, control code, and community resources are all publicly available. This significantly lowers the barrier to reproduction and makes it ideal material for STEM education and maker workshops.
From Demo to Practice: A Path for Hands-On Experimentation
This project also reflects a current trend in embedded AI: lightweight intelligence on edge devices. Edge computing refers to the paradigm of processing data locally on the device where it's generated rather than in the cloud. With the explosive growth of IoT devices, edge AI has become an important trend. Google's Coral TPU, NVIDIA's Jetson series, and various TinyML frameworks on MCUs (such as TensorFlow Lite Micro) are all driving AI capabilities toward endpoint devices.
But edge AI doesn't necessarily mean using neural networks. Tic-Tac-Toe doesn't need a deep learning model — a set of deterministic algorithms combined with traditional vision processing is more than sufficient. For tasks with limited state spaces and well-defined rules, traditional algorithms (such as decision trees, finite state machines, and classic search algorithms) are often more efficient, more reliable, and easier to debug than deep learning approaches. In compute-constrained scenarios, choosing the right algorithm is often more important than stacking models — this "right tool for the job" engineering mindset is frequently more critical in actual product development than chasing the cutting edge of technology.
For developers looking to get hands-on, here's a recommended practice path:
- Build the hardware platform: Assemble the MeArm and get the servo control working. Start with Arduino's Servo library, gradually master the mapping between PWM signals and servo angles, and complete basic forward and inverse kinematics testing.
- Implement vision recognition: Use OpenCV to achieve board detection and piece classification. It's recommended to start with static image processing — first implement perspective correction and grid segmentation, then transition to real-time video stream processing.
- Integrate decision logic: Write the Minimax algorithm and connect the entire data pipeline. You can first validate the algorithm's correctness in a pure software environment (ensuring the AI never loses), then integrate it into the complete system.
Mature open-source resources are available for reference at every step. A small project like this that combines vision, algorithms, and mechanics is an excellent starting point for understanding modern robotic systems.
Key Takeaways
Related articles

StyleX vs Tailwind: Choosing a CSS Framework in the Age of AI Agent Coding
Analyzing why Meta's StyleX may outperform Tailwind CSS when AI Agents write code—from type safety and compile-time checks to correctness at scale.

The AI Pivot Myth: From Buzzword Bandwagoning to Real Transformation
From the joke about Allbirds pivoting to AI compute, we analyze the "everything is AI" hype, show how to spot real vs. fake AI pivots, and why business fundamentals still matter.

Devin CLI Model Picker: A Deep Dive into One-Click Model Switching and Cost Comparison
Devin CLI adds a Model Picker feature for viewing available models, comparing costs, and switching effort levels. A deep dive into its three core capabilities and practical value for AI coding workflows.