Skip to content

tictactoe Game : Python-Kivy with Q-learning algorithm from Scratch

License

Notifications You must be signed in to change notification settings

aheritianad/kivy-tictactoe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TicTacToe Game

What is this?

This is a draft of a kivy app which can do basics tictactoe game. User can choose to play against cpu.

WARNING!!!

The iterface is not nice. Yeah! but it can do the job.

Why do I write this?

  • Mainly for fun
  • To apply my understanding of kivy and Q-learning free tabular

Next plan ?

  • My next plan is to implement a reinforcement learning model from scratch to allow cpu to play on its own.
  • It seems that the model plays offensive only. I will train it to play against myself after against itself when I have time for that.
  • Update with gui...
  • Still thinking and waiting for a free time

How to use it?

First of all, you need to download and install its requirement on python3.

Installation

Clone this repository by running

git clone https://github.com/aheritianad/kivy-tictactoe.git

Enter into the directory

cd kivy-tictactoe

[OPTIONAL] Create a virtual environment

Do the following if you want to run it in a virtual environment.

Create a virtual environment named .venv
python3 -m venv .venv
Activate the virtual environment you just created with
source .venv/bin/activate

Install the requirements in the environment

pip3 install -r requirements.txt

Run the game

Use the following command to run the game

python3 main.py

Solo vs Multiplayer setups

  • For solo, you can choose to either the first player or the second by setting CPU player's name by either cpu0 for easy, cpu1 for medium, cpu2 for hard or cpu3 for expert.

It is important to know that expert will upgrade after each game it plays

  • For multiplayer, only avoid cpu0, cpu1, cpu2 and cpu3 for players' names