RAS 545 · Midterm 1 · Arizona State University · Fall 2025
A fully autonomous Tic-Tac-Toe-playing robot: Minimax AI computes optimal moves, the Dobot Magician Lite physically draws symbols on paper, and a computer vision pipeline detects the human player's moves via camera.
The Dobot Magician Lite (Serial: DT-MGL-4R002-01E) is programmed to play a physical game of Tic-Tac-Toe against a human opponent. The robot draws the 3×3 grid, executes its moves by physically drawing 'X' or 'O' symbols with a pen, and uses the Minimax algorithm to guarantee optimal play. The human player draws their symbol on the board and the system tracks game state via keyboard input with a planned CV integration via opencv_to_gemini.py.
.
├── main.py # Main game loop — orchestrates vision, AI, and robot control
├── minimax.py # Minimax algorithm — optimal move selection
├── robot_draw.py # Dobot drawing control — grid, X, O symbols
├── draw_grid.py # Grid geometry and coordinate calculation
├── camera_det.py # Camera detection and initialization
├── port_connec.py # Serial port connection to Dobot
├── port_connection.py # Improved serial port handler
├── Midterm_1_report.pdf # 3-page project report (IEEE format)
└── README.md
Human input / Camera → Board state update
↓
Minimax algorithm
↓
Optimal move (i, j)
↓
Grid index → Dobot XY coordinates
↓
Robot draws symbol on board
- Algorithm: Minimax with full game tree search — guarantees robot never loses
- Human symbol: 'X' or 'O' (player choice at start)
- Turn order: Human first or Robot first (player choice at start)
- Win detection: Checks all rows, columns, and diagonals after every move
- Draw detection: Full board with no winner → "D" result
| Parameter | Value |
|---|---|
| Robot | Dobot Magician Lite |
| End effector | Pen / marker |
| Grid size | 95.0 mm outer side |
| Z draw height | 0.5 mm |
| Z travel height | 20.0 mm |
| Repeatability | ±0.2 mm |
| Max reach | 340 mm |
| Software | Python + pydobot |
The operator jogs the pen to the top-left corner of the grid at startup. All subsequent cell coordinates are computed relative to this datum using grid cell size and padding offsets — no hardcoded absolute positions.
pip install pydobot opencv-pythonpython main.pyOn startup:
- Robot auto-detects serial port and connects
- Operator jogs pen to top-left grid corner and confirms
- Robot draws the 3×3 grid
- Player selects symbol and who goes first
- Game loop begins — alternating human and robot turns
- Robot announces win / draw at game end
- Minimax guarantees optimal play but requires the internal board state to be accurate — human input errors bypass the strategy entirely
- Z-height calibration is critical: too high = no ink, too low = pen drag causes movement errors
- Defining a user-set coordinate datum at startup is far more robust than hardcoded absolute positions — adapts to any table setup
- Replacing CV board detection with keyboard input simplified deployment but removed the autonomous sensing capability
- Course: RAS 545 — Robotic and Autonomous Systems
- Instructor: Prof. Mostafa Yourdkhani
- University: Arizona State University, Tempe AZ
- Semester: Fall 2025