Our camera-guided robot plays Connect-4 against a person. It refuses boards that cannot happen, picks its move with minimax, drops a real token, and only believes the move once its camera sees it.
The robot's score for each column. The highlighted one is its pick.
Start over?
The game on the board will be cleared.
Powering on
Downloading Python for the browser
The robot is powering on. Pick a column any time: your move waits for it.
Moves aheadMinimax plays out every line this many moves deep, yours and its own in turn, then picks the best column.5What the robot ran1 to 4Answers sooner, plays weakerArduino speedThe compiled sketch runs on an emulated Arduino Uno.Full speedAs fast as your browser can. The Arduino tab shows how many times real time.Real timeThe Uno's own pace: each move takes as long as on the robot.Step by stepPauses before each step of a move, so you can follow the camera, the brain, and the Arduino one at a time.NextGoes on to the next step
Read the boardWaiting for a move
Legal move?Waiting for a move
Pick a columnScores appear above each column
Send the columnOne byte at 9600 baud
Drop a tokenWaiting for a column
Did it land?Checks only the robot's own moves
Camera picture, drawn by the pageWarped to a squareBoard as read
The camera's own view, as the robot's code reads it: column 1 is on the left.
Magazine motor
off
Encoder
0 pulses
Carriage motor
stopped at home
The robot's real code runs in your browser: the Python that reads the camera, checks the board, and plans, and the compiled Arduino sketch that drives the motors. Only the camera picture, motors, and table are simulated; the encoder speed is an assumption, and the carriage times are the sketch's own.
Watch it play
The real robot, from our final demo, in real time. The laptop shows the dashboard: minimax picks the robot's move in 0.495 s, the robot drops a red token into the board, and the camera picture updates to show it landed.
20 seconds of our final demo video, muted.
Two checks keep the game honest
Before it thinks
A new board from the camera only counts if it is exactly one legal move away from the last board the robot trusted. A chip that vanished, two new chips at once, or a chip floating above an empty cell: the robot rejects it and keeps the last good board.
After it moves
When the robot drops a token, it already knows what the board should look like. It accepts its own move only when the camera shows that exact board within 10 seconds. A token that slid into the wrong column stops the robot with an error, instead of silently corrupting the game.
The camera reads the board, a validator accepts only legal one-chip changes, minimax picks a column, the Arduino drops a token, and the camera must see the expected board before the game moves on.
From the side: the magazine and funnel sit above the board on a wooden post, beside the yellow carriage motor.
The robot
Raspberry Pi 4 reads the camera, runs the validator and minimax, and serves the dashboard.
Arduino Uno moves the carriage to the column, then releases one token with an encoder-counted magazine.
6,100 EGP in parts for the final build, about 115 USD at the April 2026 rate. An earlier design with stepper motors and a servo gate was priced at 10,135 EGP.
Results and limits
Measured on the real robot, under indoor light with a fixed camera mount. The supplement has the full tables.
Reading the board
Colour rules (HSV thresholds)
98%
Colour rules plus a learned model
96%
Learned model only
91%
Cells read correctly, out of about 200 labelled cell images. The simple thresholds did best: under steady light the board is blue and the tokens are red and yellow, and the model had little data to learn from.
Dropping a token
Column
1
2
3
4
5
6
7
Landed, of 20
20
20
20
19
19
18
17
133 of 140 drops landed in the column the robot aimed for. The misses grow toward column 7.
Time per move
3 to 15 s from an accepted board to a verified robot move, 7.5 s on average. Most of it is the mechanism and the camera check, not the image processing.
Limits
All results come from one fixed camera mount and steady indoor light. Glare and other lighting shift the colour thresholds.
The carriage has no position sensor, so the far columns miss more often.
Board detection takes the largest blue shape as the grid, so it assumes the camera sees only the board's frame: anything else blue in view, such as the board's own legs, joins it.
We did not keep the labelled images and drop logs behind the numbers above, so they cannot be re-run.
The dashboard has no login: anyone on the same network can send moves.
How it works
How the robot reads the board, what it does after each move, and where each part lives in the code.
From the paper: one board read end to end.
How it reads the board
Find the blue board frame by colour, and smooth its four corners over frames.
Warp the board to an 800 by 800 top-down view.
Brighten it (+20), stretch the contrast (×1.3), and blur it (5 by 5 Gaussian).
Cut the view into a 6 by 7 grid and read the centre of each cell as empty, red, or yellow.
After each robot move
After a move is sent the controller waits for the camera to show the expected board; a match returns it to idle, a timeout or rejected board puts it in an error state until Reset.
Where it lives in the code
vision.py finds the blue frame, warps it to 800 by 800, and reads each hole with HSV colour rules.
game_state.py is gate 1, the validator that accepts only one legal move.
minimax.py searches 5 moves ahead with alpha-beta pruning.
hardware.py sends the column over serial and runs gate 2, the camera check.
dispenser.ino drives the carriage by timing, then releases one token by encoder count. We rebuilt it from the final report, because the file that ran in the demo was not kept.
The paper and the team
Course paper, IEEE conference format, 2026
Vision-Based Connect-4 Robot: Closed-Loop Game-State Extraction and Verified Token Placement
Andrew Abdelmalak, Daniel Boules, David Girgis, Kirolous Kirolous, Samir Yacoub, Youssef Salama
MCTR 1010 Image Processing for Mechatronics, German University in Cairo, Spring 2026
With guidance from Assoc. Prof. Dr. Omar M. Shehata, Eng. Dalia M. Mahfouz, Eng. Abdelrahman Hatem, and Eng. Mohammed Ashraf
Search the paper and its supplement in your browser. It shows the three passages closest in meaning to your question, with links to their pages, and never writes an answer of its own.
On 16 test questions, a passage holding the answer is in the top three for 14.