Check my Tic Tac Toe game for bugs please

This is a discussion on Check my Tic Tac Toe game for bugs please within the Game Programming forums, part of the General Programming Boards category; it is at this thread http://www.cprogramming.com/cboard/s...654#post49010. Thanks everyone that uses it Ryan...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    66

    Check my Tic Tac Toe game for bugs please

    it is at this thread http://www.cprogramming.com/cboard/s...654#post49010. Thanks everyone that uses it

    Ryan

  2. #2
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    ;)

    Could you try making that code a little bit better... I get 12 compilation errors, even after taking out all of those stray escape sequences.

    Rewrite it and put it in [quote] tags.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,854
    The return from the getgrid() is an int between 1-9
    this is then used in a long if / else statement.

    A better way would be to use a math aproach.

    If you use a combo of / (divide) and % (remainder) you can work out the grid refrence.

    ie say 2 returned. This is array[0][1] in a zero based index.
    So to get this refrence
    1. Reduce the return from a one based to zero based index by subtracting 1 from it
    ->2-1 = 1
    2. Divide by MAXCOLUMN to get the column
    ->1/3 = 0
    3. Find the remainder for the row index
    ->1%3 = 1

    This gives array[0][1] our answer.

    say we have 9 returned
    9-1 = 8
    8/3 = 2
    8%3 = 2

    or Array[2][2] (remember is zero based eg 0-2)

    Will reduce the lenght of the code.


    PS Never, EVER, put msgbox's with comments like that in your code. It may be your work but...

    One programmer working for Apple left one like that in a product and it was released. As soon as a customer saw it they were sacked. Better to be safe than sorry. (I have been working on the same program for over two years now. Can't remember all the msgbox's.)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    66
    Mine worked on my computer what do you mean by stray escape sequences??? Thanks

    Ryan

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    66
    Here it is compiled
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    Nov 2001
    Posts
    66
    The compiler wouldn't take the \ as a continuation at school so I am wondering if that is what you are having problems with here is the revised version.


    #include <iostream.h>

    #ifndef __CHECKTACK_H__
    #define __CHECKTACK_H__


    #define CHECKTACKX(a, b) if(grid[a][b] == ' ') {grid[a][b] = 'X'; fplayer += 1;} else {cout << filled << '\n'; continue;}

    #define CHECKTACKO(a, b) if(grid[a][b] == ' ') {grid[a][b] = 'O'; fplayer -= 1;} else {cout << filled << '\n'; continue;}


    #endif

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me with my simple Tic tac toe prog
    By maybnxtseasn in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 06:25 PM
  2. tic tac toe not working properly
    By h_howee in forum Game Programming
    Replies: 2
    Last Post: 01-01-2006, 12:59 AM
  3. Replies: 22
    Last Post: 11-08-2001, 10:01 PM
  4. My tic tac toe game, please check this out.
    By Leeman_s in forum C++ Programming
    Replies: 1
    Last Post: 11-05-2001, 10:14 PM
  5. Tic tac toe (how do i check for winnner?)
    By Leeman_s in forum C++ Programming
    Replies: 3
    Last Post: 10-20-2001, 03:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21