How To make a tic-tat-toe game?

Nov 5, 2013 at 2:53pm
I need help making a tic-tat-toe game.
Nov 5, 2013 at 3:28pm
Where are you stuck?
Nov 6, 2013 at 11:00pm
This is often one of the first challenges in any programming course, and there's many ways to do it. I first encountered it in a Java course, and found it difficult until I learned about arrays. Afterwards, it was a piece of cake, and I found it easy to create a similar program in C++. I would recommend a 3x3 2 dimensional array to represent the game grid. Using integers in the array to signify empty squares, or squares filled with the X's or O's works pretty well. Ternary operators can also simplify the part of the program that checks for victories or draws. If you're unsure where to start, I'd recommend reading up on arrays, loops, and ternary operators.
Nov 8, 2013 at 12:26am
I highly appreciate you for reply to my post. I will get right on it now. Just asking how do you break down tasks and stuff? As a example :Like I want to make a statitics code which records players statitics, will rank the top players statitics. Im a beginner computer-programmer, taking courses in college.
Nov 8, 2013 at 12:39am
Sure, a good way to keep statistics for a game of tic-tac-toe is to use integer variables to track wins, losses and draws. The entire game becomes enclosed within a loop, repeating until the player chooses to exit the program, and then the statistics can be outputted. I would start by setting up your output so that it has the correct formatting for the game board (using "|" or similar characters to represent the game grid), while having the part of the program that outputs the board outputs X, O or " " instead of 1,2, or 0. The use of functions can also simplify the program, making it easier to break up tasks. For instance, a displayBoard function could be used to handle the output, and then you could determine what should happen afterwards, such as player input, victory checking, etc. It may be easier to use a function for each portion, which would make your main program more readable and easier to follow. I'll check up on this thread periodically, and if you don't manage to make further progress soon, I may have some code snippets that will help give you some ideas.
Last edited on Nov 8, 2013 at 12:42am
Topic archived. No new replies allowed.