This is a simple tic tac toe game that runs in the command line.

Overview

Tic Tac Toe Game

This is a simple tic tac toe game that runs in the command line.

Game Description:

  • The game is made up of a square grid with 9 portions. Each portion represents a slot on which a symbol can be place, either an X or an O.

The game rules are simple; A player wins when his/her symbol is placed in a manner in which a straight line can be drawn to cross over the three symbols.


This game should allow two players to compete. In a later time, we will allow the computer to make decisions.


  • My game design

    • The game contains a list of 3 lists. This is so as to form a square array with 3 rows and 3 columns, each intersection of row and column having a special index number ranging from 1-9.

    • The gameplay is done in turns. When player 1 has played, it is player 2's turn.

    • Player 1 is automatically "X" as symbol while player 2 is assigned the "O".

    • The player's entry is a number between 1 & 9, the slot where his/her symbol is placed.

    • If a slot is empty, then it is represented a "_".

    • The game ends when either of the following happens;

      • A player wins
      • There is no possibility of winning
      • The program crashes, is interrupted or closed.

How do we know if a player has won ?

The has_player_won() function returns a boolean or a string. It returns a boolean enforced to False if there is no player who has won yet. On the other hand, it will return the winning player if a player has won.

# checks if a player has won
    # we are going to use the condition above
    # we will check the leading diagonals and a cross manner
    # we will know if a player (and which player) has won if
    # we can form a straight line with 3 consecutive symbols on the grid
    # if at a certain point, a symbol fails to be the same,
    # we stop checking and move on

    # How do we know a vertical or a horizontal is formed ?
    # This is pretty tricky
    # After thinking a little, I came up with the idea that
    # If we have 3 points whose _i_ value is the same, then it forms a horizontal line -> a win
    # In the case of 3 points with equal _j_ values, then it forms a vertical line -> still a win
    # For diagonals, it is much trickier

    # chech if player won along diagonals
    # the winning slot coordinates are
    # - [(0,0), (1,1), (2,2)] or [(0,2), (1,1), (2, 0)]

    # checking along the first diagonal

Plans

My future plan are to

  • Add the computer as a second player in case you have no friend to play it with
  • Create an online web-based multiplayer tic-tac-toe game with a leaderboard.
  • Train an unbeatable Tic Tac Toe AI ;)
Owner
Josias Aurel
Self-taught hobbyist developer. Coding for fun. Making things 😜
Josias Aurel
Brawl Stars v31.96 server emulator written in Python.

Brawl Stars v31 Brawl Stars v31.96 server emulator written in Python. Requirements: Python 3.7 or higher pymongo dnspython colorama MongoDB configurat

9 Nov 26, 2021
Ghdl-interactive-sim - Interactive GHDL simulation of a VHDL adder using Python, Cocotb, and pygame

GHDL Interactive Simulation This is an interactive test bench for a simple VHDL adder. It uses GHDL to elaborate/run the simulation. It is coded in Py

Chuck Benedict 2 Aug 11, 2022
A playable version of Chess – classic two-player, various AI levels, and the crazyhouse variant! Written in Python 3

A playable version of Chess – classic two-player, various AI levels, and the crazyhouse variant! Written in Python 3. Requires the installation of PIL/Pillow and Requests

1 Dec 24, 2021
The Classic Fruit Collecting game made in python with pygame

FruitCollect A classic fruit Collecting game made with pygame Install pygame before running: "pip install pygame" Rules: Random fruits will drop from

Pranav Bobby 1 Dec 01, 2021
CTF (Capture The Flag) started from DEFCON CTF, a competitive game among computer security enthusiasts

CTF Wiki 中文 English Welcome to CTF Wiki! CTF (Capture The Flag) started from DEFCON CTF, a competitive game among computer security enthusiasts, origi

CTF Wiki 6.4k Jan 03, 2023
AutoPilot is a game where the player controls a car and tries to get the highest score he can while not dying under falling cement blocks.

AutoPilot AutoPilot is a game where the player controls a car and tries to get the highest score he can while not dying under falling cement blocks. C

Enoc Mena 1 Nov 17, 2021
Made with pygame. Multiplayer game using socket module and threading.

Rock Paper Scissor made with python-pygame. Poorly made, as a beginner in programming. Multiplayer with server code and client code provided.

AllenJo 1 Dec 29, 2021
Discord based board game, Sneks and Ladders

sneks-and-ladders Discord based board game, Sneks and Ladders intro This is the code-base for the Discord based game, Sneks and Ladders, as used for s

Yohei Nakajima 3 Nov 04, 2022
MinMax Algo , Python

Write a PYTHON program to play the game of TIC-TAC-TOE on a 3×3 board with alternate inputs from user and computer.

Naman Anand 1 Nov 26, 2021
The Bowling Club (Facebook Game) get all strikes.

TheBowlingClubBot The Bowling Club (Facebook Game) get all strikes. FAQ Q: What is this? A: TheBowlingClubBot is a automation bot with 99.99% guarante

#~Rith 1 Jan 19, 2022
Building a Mario-like, classic platformer game in Python using the PyGame Library

Building a Mario-like, classic platformer game in Python using the PyGame Library

Clarence Vinzcent Reyes 1 Feb 06, 2022
Minecraft Script to Tellraw Datapack Generator

Minecraft Script to Tellraw Datapack Geneator (STDG) can generate a chain of tellraw command in datapack from script.

1 Jan 28, 2022
Tic Tac Toe Python Game GUI

Tic Tac Toe is one of the most played games and is the best time killer game that you can play anywhere with just a pen and paper.

Astitva Veer Garg 1 Jan 11, 2022
2d war game single player

WarGame-third-version-0.0.4- 2d war game single player Hi ! Today, I publish on GitHub the version 0.0.4 of "WarGame". In this version, you can find a

Edouard Vincent 2 Apr 08, 2022
A Minecraft clone written in python and pyglet.

PyCraft A Minecraft clone written in python and pyglet. Running PyCraft To run PyCraft, run the following code: git clone https://github.com/TheWebCra

The WebCrafters 17 Dec 29, 2022
A hangman game that I created. Thanks to Data Flair for giving me the code!

Hangman A hangman game that I created. Thanks to Data Flair for giving me the code! Run python3 hangman.py in a terminal if you have Python 3. Please

SmashedFrenzy16 0 Dec 24, 2022
An single python server emulator of MMORPG game WindSlayer also known as WS1.

PySlayer An single python server emulator of MMORPG game WindSlayer also known as WS1. Requirements Python = 3.7 Old windslayer client (Korea Yahoo!

mirusu400 29 Dec 19, 2022
Utility to find games owned by all (or at least some) of the passed players.

SteamCommonGameFinder Utility to find games that are owned by all (or at least some) of the players you pass into this programm. You can already find

Daniel O'Grady 4 Jan 04, 2022
A python script to solve Wordle puzzles

Wordle solver A python script to solve Wordle puzzles.

Felix Weinberger 1 Feb 12, 2022
Wordle Tas Tool is a terminal application for solving Wordle puzzles

Wordle Tas Tool Terminal application for solving Wordle puzzles Wordle Tas Tool (WTT) is a Python script that iterates over SCOWL95 to solve Wordle pu

1 Feb 08, 2022