Search for Science Fair Projects

1000 Science Fair Projects with Complete Instructions

Computer Science Science Fair Project

Unbeatable Tic-Tac-Toe in MATLAB

Hard
Unbeatable Tic-Tac-Toe in MATLAB | Science Fair Projects | STEM Projects
Can a computer program play tic-tac-toe without ever losing? You write a script in MATLAB that first detects wins, ties, and losses on the game board. Then you build a random player that places marks in random spots. Next you program a "smart player" using roughly 300 if-then statements. Each statement counters a move that could lead to a loss. The smart player always goes second. Against the random player the program won 80 percent of 10,000 games and tied the rest. Against three human players it never lost. Humans tied 86 percent of their games and lost 14 percent.

Hypothesis

The hypothesis is that it is possible to create a computer game that never loses, even when it goes second.

Method & Materials

You will create a script that detects ties, wins, and losses. You will create a random player and have the two random players play against each other. You will then analyze strategies and program counter-attacks against moves that would result in a loss. You will then test the efficiency of the "smart player" against random players and humans.
You will need a laptop, the program MATLAB, and a basic understanding of coding.

MEL Mathhands-on math experiment kits delivered monthly — makes abstract concepts tangible. (Affiliate link)

See whats included

Results

The results of this project showed that the computer program was successful in that it was able to never lose, as seen when it played three human players. The computer program only tied 19.97% of the games against the random player, and the rest of the games the computer program won. The three human subjects, played against the computer program and never won, tied 86% of the games and lost 14%.

Why do this project?

This science project is unique because it shows how to create a computer program that can never lose a game of tic-tac-toe.

Also Consider

Experiment variations to consider include testing the computer program against more human players and testing the computer program against different strategies.

Full project details

Additional information and source material for this project are available below.
Share this Science Project:

Related Science Fair Project Ideas

CPU Speed vs. RAM Size in Computer Performance
Swap the CPU and RAM in a desktop computer and time the difference to find out which upgrade matters more.
Hard
Programming the Diffusion Equation
Write a program in Scheme that solves differential equations and use it to model how atoms spread through solids.
Hard
Billiard Ball Angles and Corner Pockets
Simulate 6,300 billiard ball paths and discover that a single property of the launch angle predicts whether the ball reaches a corner.
Hard
Share this Science Project: