Tic Tac Toe game written in pure C with computer autoplayer support. Tested with gcc 8.3.0
on Ubuntu 18.10
. This should work on all xterm terminals, but only tested on xtermjs
, konsole
, gnome-terminal
.
Online Demo: https://repl.it/@nmanumr/Tic-Tac-Toe
# Compiling & running game
make run
# Compiling & running game for xterm
make run.xterm
Currently this only works for 3x3 boards but little optimization can make it work for nxn boards also. There are two techinques we use depending on the situation.
- Corner First (when center is occupied by oponent)
- Side First (when center is occupied by computer)
This techinques goes something like following:
- If player has only one missing in row, col or diagonal mark the missing one.
- Take center if possible
- Take opposite empty corner of your oppoennt if any
- Take any of the empty corner if any
- Take empty side if any
This techinques is also very similar to Corner First but with a little order shift.
- If player has only one missing in row, col or diagonal mark the missing one.
- Take center if possible
- Take empty side if any
- Take opposite empty corner of your oppoennt if any
- Take any of the empty corner if any
- Refector code to seperate rendering, game and autoplayer logic from
include/Game.h
- Autoplayer support for
nxn
boards - (TBD) move to
ncurses
lib