can someone take a quick look at this?

This is a discussion on can someone take a quick look at this? within the C++ Programming forums, part of the General Programming Boards category; I just had some questions on the code I'm working on now 1. will it work? I'm not finished yet ...

  1. #1
    Unregistered
    Guest

    can someone take a quick look at this?

    I just had some questions on the code I'm working on now

    1. will it work? I'm not finished yet but its very long already.
    2. is there any way to make it less long?
    any other suggestion are fine.

    here's the section I'm interested in, for some reason the indentation doesn't show...

    if (emptyBoard==true)
    {row = 2;
    col = 2;}
    else if (emptyBoard==false)
    forceWin = blockLoseForceWin(Board, compSymbol, row, col); //will this work?
    else if (forceWin == false)
    blockLose = blockLoseForceWin(Board, playerSymbol, row, col);
    else if (blockLose==false)
    if (weGoFirst == false)
    {
    if (nextMove == 0)
    {
    if (Board[2][2] == ' ')
    {
    row = 2;
    col = 2;
    }
    else
    {
    row = 1;
    col = 1;
    }
    nextMove++;
    }
    if (nextMove == 1)

    }
    if (weGoFirst == true)
    {
    if(Board[2][1] != ' ' || Board[3][2] != ' ' || Board[1][2] != ' ' || Board[2][3] != ' ')
    if (nextMove == 0)
    {
    {if(Board[2][1] != ' ' || Board[3][2] != ' ')
    {row = 1;
    col = 1;}
    else if(Board[1][2] != ' ' || Board[2][3] != ' ')
    {row = 1;
    col = 3;}
    nextMove++;
    }
    }
    {if (nextMove == 1)
    {
    row = 1;
    col = 1;
    }
    nextMove++;}
    {if (nextMove == 3)
    {
    if (Board[2][1] != playerSymbol && Board[2][2] != playerSymbol && Board[2][3] != playerSymbol)
    {row = 2;
    col = 1;}
    else
    {row = 3;
    col = 1;}
    }
    }
    else if(Board[2][1] != ' ' || Board[3][2] != ' ' || Board[1][2] != ' ' || Board[2][3] != ' ')
    //check diagonals
    }

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >1. will it work? I'm not finished yet but its very long already.

    Rule #1 about programming, do it in sections. Make a small part, get it to work properly and then go on to another part. That way you get to enjoy the fun of coding and not end up tripling the time it takes to make a program by debugging for days.

    As for if it will work, I don't know. I'm not capable of compiling anything at the moment and the idea of formatting your code makes me shudder. Use the code tags here. Reformat using those tags and I'll take a look and see if there are any glaring errors.

    >2. is there any way to make it less long?

    Sure, there are plenty of ways to shorten code, but you have to consider readability. Do you want really short code that only an obfuscated code contest judge would love? Or do you want decently sized code that everyone can read and understand without too much trouble?

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 11:33 AM
  2. recursive quick sort - stack overflow
    By Micko in forum C Programming
    Replies: 9
    Last Post: 01-01-2005, 05:51 PM
  3. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM
  4. Quick Sort Help
    By NavyBlue in forum C Programming
    Replies: 1
    Last Post: 03-02-2003, 10:34 PM
  5. Replies: 0
    Last Post: 04-30-2002, 08:24 PM

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