C program, creating a tic tac toe board.

This is a discussion on C program, creating a tic tac toe board. within the C Programming forums, part of the General Programming Boards category; Hi, this is my first post on this forum. I have only taken one C class before, and that was ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    8

    C program, creating a tic tac toe board.

    Hi, this is my first post on this forum. I have only taken one C class before, and that was a long time ago. In my systems programming class, we were assigned a program that will help us review C. However, I have no idea how to go about starting this program. If anyone can give me a general direction of how to organize my program in terms of loops, how to display the board, etc, I would really appreciate it. Below I have posted the instructions for the program. I understand that I just listed my entire assignment, but i don't expect anyone to do it for me. some of the main questions i would like to know are:

    1. What is the easiest way to display the board..should I use "printf" and write out the entire board? or is there a way to use loops and create the board that way?

    2. Also, how should i go about replacing a number on the board with 'x'?

    Again, any suggestions would be helpful. thanks.

    EDIT:I just realized there was an "attach" feature, so I just attached a document of the assignment, and you do not have to read all of what is written below.
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Welcome to the forum, amitj93!

    Make a printBoard function, and use a pair of for loops. Each square on the board should be 3 chars wide, and 3 rows high, with the center being used for the 'X' or the '0' or left blank char: ' '. A '|' char will separate the squares within the row, into columns, and a '─' char will separate each row from the next one. (That's not a hyphen, it's ascii 196, and is longer than a hyphen). You'll have some arithmetic to do here to make your board look right. Each square should have a number in it, typically in the left or right hand corner.

    As with any row and column type of pattern, a nested set of two for loops, is easiest to work with. The outer for loop for the row logic (if needed), and the inner loop being the logic for each row's columns. (and will have most of the code).

    The best way to start TTT is to actually review the game first, by hand. Note the pattern you always go through, for every game. That will serve as the core of your logic for the game.

    Start with pseudo code, then refine it into your actual code. Use functions for:

    printBoard()

    isLegal() -checking if the move just made is legal or not

    isOver() - checking if the last move ended the game - win or last possible move are the only two possibilities.

    getMove() - get the move from either player.

    TTT is a great assignment because it's an easy game, but it has all the logic for a two player turn based game. You're not just adding up some numbers here. It will take longer than you think to get it right, so start ASAP, and if you get stuck, post up your code and tell us what the problem is.

    Use code tags around the code you post, and indent your code so it can be studied easily. (Advanced editor has a button for it. Highlight your code and click on it.).

    P.S. Just looked at your assignment pdf - Dabo is not Tic-Tac-Toe, and it's due in two days.
    Last edited by Adak; 01-19-2013 at 11:12 AM.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    8
    Quote Originally Posted by Adak View Post
    Welcome to the forum, amitj93!

    Make a printBoard function, and use a pair of for loops. Each square on the board should be 3 chars wide, and 3 rows high, with the center being used for the 'X' or the '0' or left blank char: ' '. A '|' char will separate the squares within the row, into columns, and a '─' char will separate each row from the next one. (That's not a hyphen, it's ascii 196, and is longer than a hyphen). You'll have some arithmetic to do here to make your board look right. Each square should have a number in it, typically in the left or right hand corner.

    As with any row and column type of pattern, a nested set of two for loops, is easiest to work with. The outer for loop for the row logic (if needed), and the inner loop being the logic for each row's columns. (and will have most of the code).

    The best way to start TTT is to actually review the game first, by hand. Note the pattern you always go through, for every game. That will serve as the core of your logic for the game.

    Start with pseudo code, then refine it into your actual code. Use functions for:

    printBoard()

    isLegal() -checking if the move just made is legal or not

    isOver() - checking if the last move ended the game - win or last possible move are the only two possibilities.

    getMove() - get the move from either player.

    TTT is a great assignment because it's an easy game, but it has all the logic for a two player turn based game. You're not just adding up some numbers here. It will take longer than you think to get it right, so start ASAP, and if you get stuck, post up your code and tell us what the problem is.

    Use code tags around the code you post, and indent your code so it can be studied easily. (Advanced editor has a button for it. Highlight your code and click on it.).

    P.S. Just looked at your assignment pdf - Dabo is not Tic-Tac-Toe, and it's due in two days.

    thanks for the response, and i am so sorry i meant to say "bingo", not tic tac toe. i was hoping people would read the attachment first, sorry about the confusion.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Plinko Board Program
    By anchorblue804 in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2012, 11:08 AM
  2. help creating the program cannot understand at all
    By moe84 in forum C Programming
    Replies: 1
    Last Post: 12-01-2011, 09:47 PM
  3. Creating a program without using any libraries
    By benrogers in forum C Programming
    Replies: 21
    Last Post: 02-28-2011, 05:38 PM
  4. Problems in creating a Battleships board
    By TheYeIIowDucK in forum Game Programming
    Replies: 2
    Last Post: 08-27-2010, 05:49 AM
  5. I need help with creating a substring program
    By CProgramingBegg in forum C Programming
    Replies: 9
    Last Post: 02-06-2009, 08:50 AM

Tags for this Thread


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