Git Product home page Git Product logo

tictactoe-lld's Introduction

TicTacToe-LLD

Table of Contents

  1. Introduction
  2. ClassDiagram
  3. ClassDescriptions
  4. GameFlow
  5. RunningGame
  6. Conclusion

Introduction

This document details the low-level design of a TicTacToe game, outlining the classes, methods, and functionality.

ClassDiagram

image

ClassDescriptions

Board

Represents the TicTacToe game board.

Attributes:

size: The size of the board (e.g., 3 for a 3x3 board).

slots: 2D list containing Slot objects.

Methods:

displayBoard(): Displays the current state of the board.

isFull(): Checks if the board is full.


Slot

Represents a single slot in the TicTacToe game board.

Attributes:

position: The position of the slot on the board.

symbol: The symbol placed in the slot (e.g., "X" or "O").

Position

Represents a position on the TicTacToe game board.

Attributes:

x: X-coordinate of the position.

y: Y-coordinate of the position.


Player

Represents a player or bot in the game.

Attributes:

name: Name of the player.

symbol: Symbol chosen by the player.

isBot: Flag indicating if the player is a bot.

move_history: List of moves made by the player.


TicTacToe

Represents the main game logic.

Attributes:

board: The game board.

players: List of Player objects.

current_player_index: Index of the current player.

row_counts, col_counts, diag_counts: Lists to keep track of the counts of each row, column, and diagonal.

Methods:

startGame(): Main game loop.

makeMove(player): Handles player's moves.

botMove(): Determines bot's move.

checkWinner(): Checks if the current player has won.

undoMove(player): Undoes the last move made by the player.


GameFlow

  1. Initialize the game by taking user input for player details and board size.
  2. Display the board.
  3. Loop until the board is full or a player has won:
    • Take the current player's move.
    • Check if they have won.
    • Switch to the next player. Display the game result.

RunningGame

To play the game, run the tictactoe_game.py file present inside tictactoe folder.

Conclusion

The low-level design of the TicTacToe game provides a detailed overview of the classes, attributes, methods, and game flow. The game supports both human players and bot players.

tictactoe-lld's People

Contributors

codingis4noobs2 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.