Okay, so I'm trying to write my own little version of Tic-Tac-Toe - and YES, I did use the search function and I saw the billions of threads involving Tictac toe. HOWEVER, I am not looking for code written for me already, I don't want to be lazy I want to learn this material - I just need a little help =(

Everytime I go to start coding my work, I never know where to start. I mean,I can get the basic text done of course, but how do I create a grid? I assume it has something to do with arrays, I was looking over some other peoples code, but I couldn't make heads or tails of a lot of it - any help would be greatly appreciated. =)

11 Years
Discussion Span
Last Post by hollystyles

Write everything on paper i.e. problems and solution that you guess, write algorithm and flowchart before you start coding. This will show you way.

To make grid make a 2D array for 3 row and column.
But if you mean that you want to make graphical grid on the console you would rather need to use System API to move through console.


Hmm... Well, I had the array part done already, that much was pretty basic to me =P

What do you mean Write an algorithm and flowchart?

I plan on making this a text based version of Tic tac Toe, but I'm sure I could produce a text table, know what I mean?


Pretty much, yeah.

I know *what* a Flowchart and algorithm is, I just don't know what I'd need an algorithim for =( I didn't code all summer (4 months ago) and just started again last week, tying to get back into it is killing me >_<'

I'm going to try and print out a tic tac toe game in the console, so I've got my array grid[3][3] and my first task will be to print the display of the grid - I just.. gotta figure out how xP


Make a function which takes your 2d array as an argument. Iterate through that array, and then print character X or O. Put some kind of line like '|' after it. Insert a new line where you will just print '----------' to make a line.


So I should make a seperate function to create the playing board, you mean? something like...


#include <iostream>
using namespace std;

int writeGrid()
cout << "
|   |   |   |
|   |   |   |
|   |   |   |
-----------" <<;

Definatly don't get how that's going to work xD


One of the hardest things for any developer is getting started. It's known as 'Analysis Paralysis' I find that one of the best techniques for breaking this impasse is to prototype. Take what you've proposed in your last post and do it anyway this can often be the catalyst that will bring the 'Aha' moment and you can see the way forward again, or realise it's really not going to work and you can scrap it and take the other route.


oh I have been messing around with a few ideas for a day or two, I'm looking for further input on what should be done - There are functions in some of the tic-tac-toe games out there, that I couldn't begin to imagine. xD

I suppose, the hardest part in this for me is going to be drawing (and redrawing) the grid, which means it'll have to be its own function...

Analysis Paralysis, eh? Haha, sounds like my kind of disorder =P


Also you're concentrating on the solution domain instead of the problem domain

You have identified you need a grid, you have decided to represent this in memory as an array. But you are using C++ so why not have a Grid class? that could have a collection (could be an array) of Cell objects (instances of Cell classes) each cell class has a render method taking a buffer or stream object as a parameter and writes itself into the buffer/stream (The grid will have a display method which iterates it's cells passing the buffer/stream to each one) then finally cout the result. The grid and cell classes don't exist you'll have to make those.

(You can see my web background putting a slant on my solution he he)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.