YEAP.. another TIC TAC TOE GAME

simple tictactoe game

  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

96 Replies - 9272 Views - Last Post: 26 March 2002 - 05:47 PM Rate Topic: -----

#1 Neutron  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 19-March 02

YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 10:42 AM

I need to write a tictactoe program but have no idea where to start off.  I don't even know how to get my board to print. It will be a simple 3x3 array. Its going to be a simple game 1 player vs computer and it will ask if you want to play again after eveyr game and alternate on who plays first.  thanks for any help and i will post any progress made in the code.

(Edited by Neutron at 12:44 pm on Mar. 19, 2002)

Is This A Good Question/Topic? 0
  • +

Replies To: YEAP.. another TIC TAC TOE GAME

#2 Neutron  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 19-March 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:06 AM

will it be easier to use the keypad as the method of determining where to put the move??

int tictactoeBoard[3][3];
progress, while little is still progress

(Edited by Neutron at 1:09 pm on Mar. 19, 2002)

Was This Post Helpful? 0
  • +
  • -

#3 SlashRaid  Icon User is offline

  • Dream.In.Force

Reputation: 1
  • View blog
  • Posts: 2,421
  • Joined: 21-January 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:24 AM

Why not use the mouse? If not, then the arrow keys highlighting the sector of your array where the 'X' or 'O' is to go???

Maybe I ask this question in stupidity, I don't know. :wink:

(Edited by SlashRaid at 1:30 pm on Mar. 19, 2002)

Was This Post Helpful? 0
  • +
  • -

#4 Neutron  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 19-March 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:27 AM

the program will open in dos window. it will ask where do you want to put your x or o.  I am thinking maybe it might ask something like this
Please enter your
row:
column:

or i could just show that the layout is like the keypad on the right of the keyboard and each number corresponds to a place.

Was This Post Helpful? 0
  • +
  • -

#5 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1868
  • View blog
  • Posts: 20,280
  • Joined: 17-March 01

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:32 AM

I think i would do it like this:

 1 | 2 | 3
-----------
 4 | 5 | 6
-----------
 7 | 8 | 9

Then just make the numbers equal the rows/column values, then replace the number with the X or O based on what the user enters

Was This Post Helpful? 0
  • +
  • -

#6 SlashRaid  Icon User is offline

  • Dream.In.Force

Reputation: 1
  • View blog
  • Posts: 2,421
  • Joined: 21-January 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:34 AM

Ahah.... I see, DOS :sad: .... Then I agree with your original idea of the key pad, nice and simple. :smile:
Was This Post Helpful? 0
  • +
  • -

#7 Neutron  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 19-March 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:38 AM

yea..thats exactly the idea i had but im still unsure of how and where to enter that

edited: are these the right steps so far??
int Board[3][3];
{ Board[0][0]= 1
 Board[0][1]= 2
 Board[0][2]= 3
 Board[1][0]= 4
 Board[1][1]= 5
 Board[1][2]= 6
 Board[2][0]= 7
 Board[2][1]= 8
 Board[2][2]= 9

//    1 | 2 | 3
//   ---|---|---
//    4 | 5 | 6
//   ---|---|---
//    7 | 8 | 9
//
//
// the top left corner is board[0][0]
// the top middle is board[0][1]
(Edited by Neutron at 1:44 pm on Mar. 19, 2002)

(Edited by Neutron at 1:53 pm on Mar. 19, 2002)

Was This Post Helpful? 0
  • +
  • -

#8 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1868
  • View blog
  • Posts: 20,280
  • Joined: 17-March 01

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:52 AM

Looks right, I'm not a C++ programmer so I can't tell you if it's totally right or not. You have the right concept though. Our C++ folks will be here in a few hours... most of them are in HighSchool so they don't get on until they get home.
Was This Post Helpful? 0
  • +
  • -

#9 Neutron  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 19-March 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:54 AM

i see. i have ideas but i just dont know how to get them out and together correctly.  
heres the most recent progress

 int Board[3][3];

{ int position;

 Board[0][0]= 1  Board[0][1]= 2  Board[0][2]= 3  Board[1][0]= 4  Board[1][1]= 5  Board[1][2]= 6  Board[2][0]= 7  Board[2][1]= 8  Board[2][2]= 9 cout<<"Where would you like to move?"<<endl; cin>>position; //    1 | 2 | 3 //   ---|---|--- //    4 | 5 | 6 //   ---|---|--- //    7 | 8 | 9 // // // the top left corner is board[0][0] // the top middle is board[0][1] // the bottom right corner is board[2][2]

void drawgame( int board[3][3] ) {    drawrow(board[0]);// draws the top row  cout << "---|---|---" << endl;  drawrow(board[1]);// draws the middlerow  cout << "---|---|---" << endl;  drawrow(board[2]);// draws the bottom row }


(Edited by Neutron at 1:58 pm on Mar. 19, 2002)

Was This Post Helpful? 0
  • +
  • -

#10 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1868
  • View blog
  • Posts: 20,280
  • Joined: 17-March 01

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:56 AM

looking better... ####... this might actually get me to learn some C++ hahaha.

Just a little tip, if you pust your code in between the [code*] CODE HERE [/code*] tags (just type them like that minus the *'s) and then uncheck the box in your post that says "Enable  Emoticons" we'll be able to read it a bit better.


Was This Post Helpful? 0
  • +
  • -

#11 Neutron  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 19-March 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 11:59 AM

cool..and thanks
here is more ideas..they are not in order (at least i think so) but its best to get my ideas out first.
#include <iostream.h>

void drawgame(matrix board); int Board[3][3];

{ int position;

 Board[0][0]= 1  Board[0][1]= 2  Board[0][2]= 3  Board[1][0]= 4  Board[1][1]= 5  Board[1][2]= 6  Board[2][0]= 7  Board[2][1]= 8  Board[2][2]= 9 cout<<"Where would you like to move?"<<endl; cin>>position; if (position ==1) board[0][0]='X', for(int i=0; i<3; i++) { for(int j=0; i<3; i++) { cout<<board[i][j]; } cout<<endl; } //    1 | 2 | 3 //   ---|---|--- //    4 | 5 | 6 //   ---|---|--- //    7 | 8 | 9 // // // the top left corner is board[0][0] // the top middle is board[0][1] // the bottom right corner is board[2][2]

void drawgame( int board[3][3] ) {    drawrow(board[0]);// draws the top row  cout << "---|---|---" << endl;  drawrow(board[1]);// draws the middlerow  cout << "---|---|---" << endl;  drawrow(board[2]);// draws the bottom row }

(Edited by Neutron at 2:05 pm on Mar. 19, 2002)

Was This Post Helpful? 0
  • +
  • -

#12 WYRViNX  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 75
  • Joined: 14-March 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 12:29 PM

Do you have to use a two-dimentional array?
Was This Post Helpful? 0
  • +
  • -

#13 eurotrash  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 05-November 01

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 01:18 PM

okay...

I like the idea...

Now that I'm thinking about it's going to be a hard little project.

Okay you have the right idea by in using a two dimensional array for the printing. I think it would be a hassle to use it for the varibels as well.

The crux of thge program is going to be figuring out the logic used to determine a win, loss, draw and invalid moves.

To make this easier I'd sugguest that you make a two classes, a class for the logic and a class for the tic tac toe board.

the tic tac toe class would have private varibels, for each space on the board, and public member fucntions tha would keep track of the chocies each player made.

the logic class would need to be able to look at the choices each player has made then evaluate weather or not it is a win, draw or the gaem continues.

once your classes are built, in the main fucntion declare two objects, eg player1 and player2 and one for the logic. and you need to do is call the member fucntions as needed...

heope this helps

Was This Post Helpful? 0
  • +
  • -

#14 Neutron  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 19-March 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 01:51 PM

i'm lost by what you mean for the two classes. what exactly is a class

also it will be a one player game.

(Edited by Neutron at 3:53 pm on Mar. 19, 2002)

wat compilier/program do you guys use for c++.  i currently use Dev-C++ and it gives me some wiered errors at times, but I don't know of another free one.

(Edited by Neutron at 3:55 pm on Mar. 19, 2002)

Was This Post Helpful? 0
  • +
  • -

#15 WYRViNX  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 75
  • Joined: 14-March 02

Re: YEAP.. another TIC TAC TOE GAME

Posted 19 March 2002 - 02:16 PM

    Hey mon, what's this project for?  A class is an advanced topic dealing with Object Oriented Programming.
  Oh, and Compiler = M$ VC++, it was 贄 ,but it came packaged w/ WinNT!

(Edited by WYRViNX at 4:25 pm on Mar. 19, 2002)

Was This Post Helpful? 0
  • +
  • -

  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »