Skip to content
AVR ATTINY Tic Tac Toe Game
C Makefile C++
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Makefile
README.md
iolib.c
iolib.h
mcu.c
mcu.h
schematics.jpg
tictactoe.jpg
ttt.c
ttt.h

README.md

TINY Tic Tac Toe

This project was developed back in 2004 for the Atmel ATTINY Circuit Cellar Contest.

This Tic Tac Toe game has a 3x3 dual color LED matrix, a 3x3 keypad scan, and the algorithm necessary to make the game impossible to beat. Everything was designed to fity on an ATTINY26 AVR with 2Kb of flash.

Here is a video of the game in action. https://www.youtube.com/watch?v=x-JH1wQzx94

Losing the Game

As it is commonly known, Tic Tac Toe is no mystery, if you aren't the first to start the game there is no way to win it, you can only tie the game.

The winning and blocking rules are easy to figure out.

The software follows the these rules top to bottom:

  • If the board is empty: Pick a corner.
  • If You've already marked 2 positions on a line and the third one is free: Mark the third to win.
  • If your opponent has already marked 2 positions on a line and the third one is free: Mark the third to defend.
  • If the center is free: Mark the center.
  • If the opponent has marked 2 adjacent lateral middle positions: Mark the corner in between.
  • If all corners are still free (may happen if the opponent began): Mark a random corner.
  • If you've already marked a corner: Mark an opposing free corner.
  • If you have the center: Mark on a line to keep the opponent busy. And prevent the opponent from winning with the three corners move.
  • Try to conquer three corners: Mark a random free corner.
  • It is going to be a tie anyway: Mark on a random free position.
You can’t perform that action at this time.