/online-tictactoe

GUI online TicTacToe using pygame and socket lib.

Primary LanguagePythonMIT LicenseMIT

Welcome to online TicTacToe game 👋

Python version: 3.x License: MIT Docstrings: reStructuredText Code style: black

online-tictactoe is a GUI online pygame version of tictactoe game with AI, server-side and client network has been created using python socket lib.


Online-TicTacToe (Client)

Online-tictactoe client is a client-side part of online-tictactoe game using python pygame lib aim to make a wonderful GUI for tictactoe game with simple network using socket and pickle lib.

Usage 🗝

There are two ways to use the client side :

  • Using exe version without any requirements :

    • Download entire exe dir.

    • Configure server.yaml file (set server host & port).

    • Run exe/main.exe.

    • Start playing!

      ttt-interface

  • Using runner.sh :

    • Install requirements :

      $ sudo pip3 install -r requirements.txt
    • Run the game :

      $ ./runner.sh g
    • Start playing!

      ttt-interface

Demo 🧮

You can playing with any connected enemy or playing with AI.

Play Online (online)

Start the server to start playing

  • configure server.yaml file for client.

  • start the server.

    start-the-server

Start playing with stable connection!

  • choose empty square using (mouse/keyboard).

  • hit enter to set a value.

  • wherever you play, your enemy will see the result immediately.

    state-share

Winning / Losing cases

  • the game will reseted.

  • your symbol will changed.

    win-lose-cases

Play With AI (offline & online)

Change from online mode to AI mode

  • press 'Play With AI' button.
  • game will reseted and connection will not recv any data.
  • there are four AI engine levels :
    • the level will automatically increased when you win.

    • maximum level is 4.

    • after each game you'll get a new playing symbol.

      change-to-ai-mode

Set value and get AI response

  • choose empty square using (mouse/keyboard).

  • hit enter to set a value.

  • you'll get an AI response.

    ai-res

Winning case

  • AI engine level will increased.

  • the game will reseted.

  • your symbol will changed.

    win

Losing case

  • AI engine level will not increased.

  • the game will reseted.

  • your symbol will changed.

    lose

Tests 🧪

Test dir include tests for two classes :

Run instructions :


Online-TicTacToe (Server)

Online-tictactoe server is a server-side part of online-tictactoe game using python socket lib and pickle lib aim to make a stable connection between two threaded tictactoe players and send/recv data from/to players as objects using pickle lib.

Usage 🗝

There are two ways to use the server :

  • Using exe version without any requirements :

    • Download entire exe dir

    • Configure server.yaml file (set server host & port)

    • Run exe/main.exe

    • Press start button

      server gui jpg

  • Using runner.sh and there are three ways:

    • Inside your machine (both CLI & GUI) :

      • Install requirements:
        $ sudo pip3 install -r requirements.txt
      • Configure server.yaml file (set server host & port)
      • CLI :
        $ ./runner.sh c
      • GUI :
        $ ./runner.sh g
    • Inside docker container (only CLI version) :

      • Configure server.yaml file (set server host & port)
      • Build and run docker :
        $ ./runner.sh host port
        $ ./runner.sh 0.0.0.0 6000

Tests 🧪

The entire server.server.Server unit tests include within tests directory

Run instructions :

  • Install requirements:
    $ sudo pip3 install -r requirements.txt
  • Run tests using runner.sh
    $ ./runner.sh t

Copyright ©

👤 Hadi Alqattan

📝 License

Copyright © 2020 Hadi Alqattan.
This project is MIT licensed.


Give a ⭐️ if this project helped you!