Skip to content

A Lightweight, Pure Java Neural Network for Tic Tac Toe. No TensorFlow, No Bloat - just a ~60 KB Jar. Think You Can Win?

License

Notifications You must be signed in to change notification settings

NeuroMachinesLab/tic-tac-toe-game

Repository files navigation

java-version

Pure Java Neural Network Tic Tac Toe Game

tic-tac-toe-game

This console program allows you to read Neural Network from the network-easy.txt, network-medium.txt or network-hard.txt file and play the Tic Tac Toe console Game.

To play the game run:

.\mvnw.cmd clean package
java -jar .\target\tic-tac-toe-game-1.0.jar

The Neural Network is based on Perceptron [1] and trained by Q-Learning [2] data with the program from repository [3].

Neural network parameters

Game difficulty Network parameters How often the model identifies the optimal move, %
Easy 66 54.6
Medium 180 75.9
Hard 1225 98.4

[1] Perceptron
[2] Q-Learning
[3] Neural Network

Console interface

Example of one game:

> java -jar .\target\tic-tac-toe-game-1.0.jar

1) Easy
2) Medium
3) Hard
Choose Difficulty  [1-3]: 3

1) X player
2) O player
Select a player [1-2]: 1

| 1 | 2 | 3 |
-------------
| 4 | 5 | 6 |
-------------
| 7 | 8 | 9 |

Move with 'X' to space [1-9]: 6

|   |   |   |
-------------
|   |   | X |
-------------
|   |   |   |

AI move: 3

|   |   | O |
-------------
|   |   | X |
-------------
|   |   |   |

Move with 'X' to space [1-9]: 4

|   |   | O |
-------------
| X |   | X |
-------------
|   |   |   |

AI move: 5

|   |   | O |
-------------
| X | O | X |
-------------
|   |   |   |

Move with 'X' to space [1-9]: 7

|   |   | O |
-------------
| X | O | X |
-------------
| X |   |   |

AI move: 1

| O |   | O |
-------------
| X | O | X |
-------------
| X |   |   |

Move with 'X' to space [1-9]: 2

| O | X | O |
-------------
| X | O | X |
-------------
| X |   |   |

AI move: 9

| O | X | O |
-------------
| X | O | X |
-------------
| X |   | O |

Good game, but you lost

About

A Lightweight, Pure Java Neural Network for Tic Tac Toe. No TensorFlow, No Bloat - just a ~60 KB Jar. Think You Can Win?

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages