TIC TAC TOE - Java Edition

Dependencies

This game requires that you have java and maven installed on your machine.

Please run java -version from the command line to check if you have java.

If you have Java, your output should be similar to the one below.

YouHaveJava

If you get a different output, then follow the instructions at this link: Getting Java 9

Once you've installed Java, you'll need to make sure you have Maven so that you can create a game package and run the test suites.

Please run mvn --version from the command line to check if it is installed.

If you have Maven, your output should be similar to the one below.

YouHaveMaven

If you get a different output, then the easiest way to get started is with the package manager Homebrew. To check if you have Homebrew, please run brew --version.

If you don't, installation is very easy, just follow the instructions at this link: Installing brew. Once you have Homebrew, you can install maven using the command brew install maven.

Getting started

  1. Run git clone https://github.com/GeorgeSmith-Sweeper/JavaTTT.git in your terminal.

  2. Run cd JavaTTT.

  3. Run mvn package at the root.

  4. Run java -jar target/JavaTicTacToe-1.0-SNAPSHOT.jar at the root to start the game.

Playing the Game

The game will begin by displaying a prompt for a board size.

Board Size Prompt

Next you can select symbols for the player 1, and player 2.

Player 1 Symbol

Player 2 Symbol

Next is a game mode prompt.

Game Mode Prompt

If you've chosen to play against the Ai you will be given the option of three difficulty levels.

Difficulty Level Prompt

Finally you will be asked if you would like to have the first move.

Who Move First

Tests

There are 61 tests for this game! The tests can executed my running mvn test at the root.

Points of interest

The computer is unbeatable when played on a standard 3x3 board (seriously it's kind of a jerk), however when played on boards of 4x4 or greater, it gets bogged down in move computations, and fails to make a move in an acceptable time. The next version of Tic-Tac-Toe will add Alpha-Beta pruning to my negamax function, in order to prune number of branches that the computer must search for the 'best move'. This will allow the computer to handle larger board sizes while remaining unbeatable.

Posts by crafters at 8th-Light who also did negamax:

Joys of minimax and negamax

Ruby tic tac toe negamax with alpha beta pruning