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
Racers-API - a game where you have to go around racing with your car, earning money

Racers-API About Racers API is a game where you have to go around racing with yo

3 Jan 09, 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
A python snake game based on pygame.

PySnake A python snake game based on pygame. Requirements Package version pygame = 2.1.2 opencv-python = 4.5.1.48 Run Windows python main.py Linux &

2 Jan 31, 2022
Useful tools for Minecraft worlds such as remove unused chunks, find blocks or entities.

Useful tools for Minecraft worlds such as removing unused chunks and finding blocks, command blocks or entities.

Rapha149 1 Feb 17, 2022
Simple python program to simulate Conway's game of life with custom variables.

ConwaysGameOfLife Simple python program to simulate Conway's game of life with custom variables. Custom Variables Grid-size : Change the size of the p

davidgasinski 1 Oct 28, 2021
This is a python implementation of wordle, which uses the same set of available words as the hit game, Wordle

Wordle Game This is a python implementation of wordle, which uses the same set of available words as the hit game, Wordle. Play the game manually pyth

Pierre Theo Klein 11 Mar 04, 2022
BUBBLE SHOOT - Pygame (python)

BUBBLE-SHOOT---Pygame BUBBLE SHOOT - Pygame (python) Bubbleshooter This is a Bubble shooter Game made with pygame. The arrow is controlled by the arro

ROBIN JONEY 1 Nov 12, 2021
A stat tracker for the bedwars hypixel game in python

A hypixel bedwars stat tracker. Features Get stats in your current lobby Get stats in a guild Installation & Configuration git clone https://github.co

Le_Grand_Mannitout 3 Dec 25, 2021
A simple log-frequency helper for solving Wordle puzzles

A Simple Helper for Wordle Basic Usage Clone the repo and run python play.py Select a word from the list, or type your own choice of word Type the sam

Christian Casey 2 Feb 14, 2022
A project to san the internet of all open Minecraft servers.

MC-Server-Finder A project that scans the internet to find open Minecraft servers. Install the dependencies by running pip install -r requirements.txt

drakeerv 8 Mar 12, 2022
Blackjack-Py is a terminal based game of blackjack within your terminal playing against CPU.

About Blackjack-Py is a terminal based game of blackjack within your terminal playing against CPU. Usage Clone the repo and run it with whatever pytho

Eccentrici 1 Dec 28, 2021
A programme which basically has the same function as the actual Rock paper scissors game.

A programme which basically has the same function as the actual Rock paper scissors game.

1 Feb 11, 2022
Made by Ashish and Avinash-sord12k. Powered by pygame

Spook_alle About -Made by Ashish (Github: Ashish-Github193) and Avinash-sord12k Version - BETA v_1.0 /1-11-2021/ (game is at its base version more ite

Ashish Kumar Jha 1 Nov 01, 2021
An open source Python library for the Snake retro game.

An open source Python library for the Snake retro game.

3 Jul 13, 2021
j-chess implementation in python

j-chess-client-python This repository aims to be a starting point for implementing a chess ai for the j-chess-server in python. To start, you can copy

Jonas 1 Dec 25, 2021
Small game I made in 2019 using python/pygame.

Kill-The-Blokk // Shoot or Die This is a small game I made in gr.10 (2019) for my high school computer science class; the game was coded in python usi

1 Nov 13, 2021
This is a simple Tic Tac Toe game built with Python.

This is a simple Tic Tac Toe game built with Python.

⚝αикιт кυмαя⚝ 6 Sep 01, 2022
Pong is one of the first computer games that ever created, this simple

Pong-Game Pong is one of the first computer games that ever created, this simple "tennis like" game features two paddles and a ball, the goal is to de

Lateefah Ajadi 0 Jan 15, 2022
Deal Or No Deal was a very popular game show. Even now, for a family party, it's a fun game to pass time

Deal Or No Deal was a very popular game show. Even now, for a family party, it's a fun game to pass time. I made a code to play the game right in your terminal/console. This isn't made to be a game w

1 Feb 15, 2022
This project is an exciting fun game for beginners to build up

This project is an exciting fun game for beginners to build up. The program generates a random number from 1 to 10, or 1 to 100 any range that is specified and the user must guess the number after a

PyLaboratory 0 Feb 07, 2022