Giter Site home page Giter Site logo

pratham-099 / tic-tac-toe Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 1.52 MB

This is a C# Windows Forms application for a Tic Tac Toe game. It uses a 2D array of buttons to represent the game board and has event handlers for each button. The game keeps track of player turns, checks for a winner after each move, and displays a message box when a player wins a round.

C# 100.00%
csharp csharp-code game tic-tac-toe

tic-tac-toe's Introduction

Tic-Tac-Toe

Tic Tac Toe

This is a Player vs Player Tic Tac Toe game using C# programming language. It allows users to play total 5 rounds. This is a 2 Player game and players has to choose their respective symbols before playing.

Files & DIRECTORIES

  • TicTacToe.sln : A text-based file that contains information about the project environment, state, and name-value parameters. This is a structure file used for organizing this project in Microsoft Visual Studio.
  • Tic-Tac-Toe.cs : The file that contains the source code of the whole project.
  • Tic-Tac-Toe.Designer.cs : The designer file has the code automatically generated by the designer to hold the form’s layout information that was created using the Visual Studio IDE.
  • Setup : The "Setup" directory is constaining files that are used to create an installation package for this application, they can be used to distribute the project to end-users.
  • setup.exe : An executable file (EXE file) that is containing an encoded sequence of instructions that the system can execute directly when the user will click the file icon.

Source Code

  • Tic-Tac-Toe.cs has the source code for performing the Tic Tac Toe game in C#. It defines a 2D array of buttons to represent the game board and initializes the game board by assigning each button to its corresponding button on the form. It also declares variables to keep track of the game state, including the number of rounds played, the number of buttons clicked, the current player symbol (X or O), and the number of wins for each player.
  • The turn_decider() function determines which player's turn it is based on the number of buttons clicked so far.
  • The game board has event handlers for each button to handle the button click event. When a button is clicked, the turn_decider() function is called to determine the current player's symbol, and the symbol is displayed on the button and the buttons are then disabled.
  • If the number of buttons clicked is greater than or equal to 5, the check_winner() function is called to check if there is a winner for the round.
  • The check_winner() function checks if there is a winner for the current round by checking each row, column, and diagonal of the game board. If there is a winner, a message is displayed, the win count for the corresponding player is incremented.
  • The necessary_calculations() function is called to update the score.
  • The clear() function is also called to reset the game board for the next round.

Design

Tic Tac Toe
  • The design has several buttons, labels.
  • The buttons are used to create a Tic Tac Toe game board.
  • The labels will display information such as the current round number and the scores for player O and player X.

Functionality

Tic Tac Toe Tic Tac Toe Tic Tac Toe
  • Each player selects their respective symbols to play.
  • Whenever the X wins or O wins, winning message of the resposible player is displayed and their score is incremented. In the event of draw, the message for a draw match is displayed and their is no increment in the score of any player.
  • If Both the player has same score even after 5 rounds a super round is played to dermine the winner.

Installation

Here are the steps to install and run the Tic-Tac-Toe game from this GitHub repository

  • Go to the GitHub repository at https://github.com/PRATHAM-099/Tic-Tac-Toe
  • Click on the green "Code" button and select "Download ZIP" to download the code as a zip file.
  • Extract the contents of the downloaded zip file to a folder on your computer.
  • Open a command prompt or terminal window and navigate to the extracted folder using the "cd" command.
  • Once you are inside the project folder, you will find a file named "tic_tac_toe.exe". This is the executable file that you need to run to play the game.
  • Run the executable file by typing "tic_tac_toe.exe" in the command prompt or terminal window and pressing Enter.
  • The Tic-Tac-Toe game will now start. Follow the on-screen instructions to play the game.
  • That's it! You have successfully installed and run the Tic-Tac-Toe game.

tic-tac-toe's People

Contributors

prathamr-codes avatar

Stargazers

Avogato The Cat Lover avatar

Watchers

Pratham Rathod 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.