# My first tiectactoe.cpp, need help debugging

This topic is 4205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

const int BOARD_MAX = 8;
const string EMPTY = " ";
const char X = 'X';
const char O = 'O';
const char NO_ONE = 'N';
const char TIE = 'T';

void instructions();
void DisplayBoard(const vector<string>& board);
char WhoGoesFirst();
char Opponent(char Humanturn);
char winner(const vector<string>& board);
bool IsLegal(const vector<string>& board, int move);
int HumanMove(const vector<string>& board);
int AskNumber(string question, int high, int low);
int ComputerMove(vector<string>& board, char Computerturn);
char winner(const vector<string>& board);
void AnnounceWinner(char winner, char Humanturn, char ComputerTurn);

int main()
{
int move;
instructions();
vector<string>board(BOARD_MAX, EMPTY);
char Humanturn = WhoGoesFirst();
char Computerturn = Opponent(Humanturn);
char turn = 'X';
DisplayBoard(board);

// main game loop
while(winner(board) == NO_ONE)
{
if(Humanturn == turn)
{
move = HumanMove(board);
board[move] = Humanturn;
}
else
{
move = ComputerMove(board, Computerturn);
board[move] = Computerturn;
}
DisplayBoard(board);
turn = Opponent(turn);
}

AnnounceWinner(winner(board), Humanturn, Computerturn);
system("PAUSE");
return 0;
}

inline bool IsLegal(int move, const vector<string>& board)
{
return(board[move] == EMPTY);
}
void instructions()
{
cout << "\tThis is Tic-Tac-Toe." << endl;
cout << "You will be pit against the most intelligent machine known to man, the computer.";
cout << "The instructions are sipmle, pick a number that corresponds that with the grid\nto place your move there." << endl;
cout << "\tPrepared?";
}

{
do {
cout << endl << question;
}
}

char WhoGoesFirst()
{
char First = AskQuestion("Do you want to go first human?");
if(First == 'y')
{
cout << endl << "Alright, your move...";
return X;
}
else
{
cout << endl << "Hmm, my turn...";
return O;
}
}

char Opponent(char Humanturn)
{
if(Humanturn == X)
{
return O;
}
else
{
return X;
}
}

int AskNumber(string question, int high, int low)
{
int move;
do{
cout << question << " (" << low << " - " << high << " ).";
cin >> move;
}
while(move < low || move > high);
return move;
}

void DisplayBoard(const vector<string>& board)
{
cout << "\n| " << board[0] << " | " << board[1] << " | " board[2] " |" << endl;
cout << "- - - - - - - - -";
cout << "\n| " << board[3] << " | " << board[4] << " | " board[5] " |" << endl;
cout << "- - - - - - - - -";
cout << "\n| " << board[6] << " | " << board[7] << " | " board[8] " |" << endl;
}

int HumanMove(const vector<string>& board)
{
int move = AskNumber("\n Where do you want to move, human?", 0, 8);
if(IsLegal(move, board))
{
return move;
}
else
{
int move = AskNumber("\nWhere do you want to move, human?", 0, 8);
}
}

int ComputerMove(const vector<string>& board, char Computerturn)
{
cout << "\nIt is my turn now...\n";

//lets see if the computer can win on the next move with a for loop
for(int move = 0; move < board.size(); ++move)
{
board[move] = Computerturn;
if(IsLegal(board, move))
if(winner(board) == computer)
{
return move;
}
board[move] = EMPTY;
}
}
//lets tell this function's scope that the human's piece is equal to the opposite of the computer's piece
char human = Opponent(Computerturn)
//lets see if the human can win on the next turn with a for loop
for(int move = 0; move < board.size(); ++move)
{
if(IsLegal(move, board))
{
board[move] = human;
if(winner(board) == human)
{
return move;
}
board[move] = EMPTY;
}
}

vector<int> AllMoves;
AllMoves.push_back(0);
AllMoves.push_back(1);
AllMoves.push_back(2);
AllMoves.push_back(3);
AllMoves.push_back(4);
AllMoves.push_back(5);
AllMoves.push_back(6);
AllMoves.push_back(7);
AllMoves.push_back(8);
srand(time(0));
random_shuffle(AllMoves.begin(), AllMoves.end());

//lets take this vector and decide which random move the computer makes
for(int i = 0; i < board.size(); ++i)
{
int move = AllMoves[i];
if(IsLegal(move, board))
{
return move;
}
}

char winner(const vector<string>& board)
{
int WinningMoves[] = { {0, 1, 2},
{3, 4, 5},
{6, 6, 8},
{0, 3, 6},
{1, 4, 7},
{2, 5, 8},
{2, 4, 6},
{0, 4, 8} };

//lets see if someone has a winning combination
for(int i = 0; i < board.end(); ++i)
{
if( (board[WinningMoves[i][0]] != EMPTY) && (board[WinningMoves[i][0]] == board[WinningMoves[i][0]]) &&
(board[WinningMoves[i][1]] == board[WinningMoves[i][2]]) )
{
return board[WinningMoves[i][0]];
}

if(count(board.begin(), board.end(), EMPTY) == 0)
{
return TIE;
}

return NO_ONE;
}

void AnnounceWinner(char winner, char Humanturn, char ComputerTurn)
{
if(winner == Humanturn)
{
cout << "\nYou have won human...I will accept defeat.\n";
}

if(winner == Computerturn)
{
cout << "\nI have crushed you human!  Proof that we computers, are smarter then\nyou!\n";
}

if(winner == TIE)
{
cout << "\nNo one has won, and the race between humans and computers still ensues.\n";
}

}


Looks like i've finished my first TicTac Toe, but I'm getting numerous compile errors that I can't quite figure out. Any help is appreciated, thanks.
Compile Log
-------------------------------
Compiler: Default compiler
Executing  g++.exe...
g++.exe "E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp" -o "E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.exe"   -g3  -I"D:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"D:\Dev-Cpp\include\c++\3.4.2\backward"  -I"D:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"D:\Dev-Cpp\include\c++\3.4.2"  -I"D:\Dev-Cpp\include"   -L"D:\Dev-Cpp\lib" -g3
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp: In function void DisplayBoard(const std::vector&lt;std::string, std::allocator&lt;std::string&gt; &gt;&)':
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:122: error: expected ;' before "board"
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:124: error: expected ;' before "board"
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:126: error: expected ;' before "board"

E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp: In function int ComputerMove(const std::vector&lt;std::string, std::allocator&lt;std::string&gt; &gt;&, char)':
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:149: error: passing const std::string' as this' argument of std::basic_string&lt;_CharT, _Traits, _Alloc&gt;& std::basic_string&lt;_CharT, _Traits, _Alloc&gt;::operator=(_CharT) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, _Alloc = std::allocator&lt;char&gt;]' discards qualifiers

E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:151: error: computer' undeclared (first use this function)
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:151: error: (Each undeclared identifier is reported only once for each function it appears in.)
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:155: error: passing const std::string' as this' argument of std::basic_string&lt;_CharT, _Traits, _Alloc&gt;& std::basic_string&lt;_CharT, _Traits, _Alloc&gt;::operator=(const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, _Alloc = std::allocator&lt;char&gt;]' discards qualifiers

E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp: At global scope:
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:159: error: Computerturn' was not declared in this scope
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:161: error: expected ,' or ;' before "for"
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:161: error: expected constructor, destructor, or type conversion before '&lt;' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:161: error: expected ,' or ;' before '&lt;' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:161: error: expected unqualified-id before '++' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:161: error: expected ,' or ;' before '++' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:175: error: expected constructor, destructor, or type conversion before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:175: error: expected ,' or ;' before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:176: error: expected constructor, destructor, or type conversion before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:176: error: expected ,' or ;' before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:177: error: expected constructor, destructor, or type conversion before '.' token

E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:177: error: expected ,' or ;' before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:178: error: expected constructor, destructor, or type conversion before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:178: error: expected ,' or ;' before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:179: error: expected constructor, destructor, or type conversion before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:179: error: expected ,' or ;' before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:180: error: expected constructor, destructor, or type conversion before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:180: error: expected ,' or ;' before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:181: error: expected constructor, destructor, or type conversion before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:181: error: expected ,' or ;' before '.' token

E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:182: error: expected constructor, destructor, or type conversion before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:182: error: expected ,' or ;' before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:183: error: expected constructor, destructor, or type conversion before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:183: error: expected ,' or ;' before '.' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:184: error: expected constructor, destructor, or type conversion before '(' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:184: error: expected ,' or ;' before '(' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:185: error: expected constructor, destructor, or type conversion before '(' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:185: error: expected ,' or ;' before '(' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:188: error: expected unqualified-id before "for"

E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:188: error: expected ,' or ;' before "for"

E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:188: error: expected constructor, destructor, or type conversion before '&lt;' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:188: error: expected ,' or ;' before '&lt;' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:188: error: expected unqualified-id before '++' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:188: error: expected ,' or ;' before '++' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp: In function char winner(const std::vector&lt;std::string, std::allocator&lt;std::string&gt; &gt;&)':
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:207: error: brace-enclosed initializer used to initialize int'
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:207: error: brace-enclosed initializer used to initialize int'
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:207: error: brace-enclosed initializer used to initialize int'
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:207: error: brace-enclosed initializer used to initialize int'
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:207: error: brace-enclosed initializer used to initialize int'
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:207: error: brace-enclosed initializer used to initialize int'
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:207: error: brace-enclosed initializer used to initialize int'
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:207: error: brace-enclosed initializer used to initialize int'
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:210: error: no match for 'operator&lt;' in 'i &lt; (+board)-&gt;std::vector&lt;_Tp, _Alloc&gt;::end [with _Tp = std::string, _Alloc = std::allocator&lt;std::string&gt;]()'
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:212: error: invalid types int[int]' for array subscript
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:212: error: invalid types int[int]' for array subscript
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:212: error: invalid types int[int]' for array subscript
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:213: error: invalid types int[int]' for array subscript
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:213: error: invalid types int[int]' for array subscript
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:215: error: invalid types int[int]' for array subscript
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:227: error: a function-definition is not allowed here before '{' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:227: error: expected ,' or ;' before '{' token
E:\Documents and Settings\Kev\Desktop\Book Exercizes\MyFirstTicTacToe.cpp:243: error: expected }' at end of input

Execution terminated



##### Share on other sites
for starters, in DisplayBoard:
void DisplayBoard(const vector<string>& board){     cout << "\n| " << board[0] << " | " << board[1] << " | " board[2] " |" << endl;     cout << "- - - - - - - - -";     cout << "\n| " << board[3] << " | " << board[4] << " | " board[5] " |" << endl;     cout << "- - - - - - - - -";     cout << "\n| " << board[6] << " | " << board[7] << " | " board[8] " |" << endl;}

you are missing "<<" operators before amd after board[] 2, 5, and 8:

void DisplayBoard(const vector<string>& board){     cout << "\n| " << board[0] << " | " << board[1] << " | " << board[2] << " |" << endl;     cout << "- - - - - - - - -";     cout << "\n| " << board[3] << " | " << board[4] << " | " << board[5] << " |" << endl;     cout << "- - - - - - - - -";     cout << "\n| " << board[6] << " | " << board[7] << " | " << board[8] << " |" << endl;}

also, keep in mind that the errors will give you the exact line the problem is on, and in most IDEs, double clicking on the error will take you right to that line of code, to help with error fixing.

##### Share on other sites
thanks, I just noticed that myself :]

##### Share on other sites
Wow thats a lot of errors. I'm not about to debug the whole thing...but I'll tell you a few things that cought my eye first.

look in your DisplayBoard(const vector<string>& board). You are missing the << marks towards the end of 3 of the statements.

Line 151..you put if(winner(board) == computer) when you never even made a computer variable.

you are trying to convert things that cannot be converted such as Line 149 board[move] = Computerturn;

you forgot lots of ; such as Line 159.

on Line 200 you are trying to define a 1D array as a 2D array. int WinningMoves[] should be changed to int WinningMoves[][]

you also try to return arrays of something when the function is a char function...such as your winner(const vector<string>& board) function.

Theres loads more...but I'll leave it up to you to find the rest :) Just know you are trying to do a lot of illegal conversions. lol this will probably not be fun for you. good luck!

##### Share on other sites
Ok, well at my AllMoves vector, what could POSSIBLY be the problem, I'm just pushing back numbers...

##### Share on other sites
Ok, I've knocked a few errors out, but now on line 160, its saying that Computerturn wasn't defined in this scope...COMPUTERTURN IS WHAT I'M PASSING TO THE FUNCTION! HOW CAN IT NOT BE IN THE FUNCTION'S SCOPE?!?! :]

##### Share on other sites
correct me if I'm wrong...but Allmoves is not an object of anything. What you are doing is trying to call something from an object named Allmoves, which does not exist.

##### Share on other sites
::Confusion::

AllMoves is my vector of ints, I'm simply trying to push back the numbers 1-8 into the vector's containers.

##### Share on other sites
woops sorry bout that..

I havn't really used vectors in the way you are using them quite that much. In fact, your whole project looks too over complicated. Not trying to be rude or anything..I just think a lot of the things you did, could have been done in a much more simple way.

With that in mind...it's kind of hard to debug somebody elses code, because you aren't familiar with the intentions that the coder had. Basically..the person who made the code is the best person to debug the code. Just keep playing with things going wrong and eventually the answer will hit you. Sometimes..all it takes is a little trial and error.

best of luck!

##### Share on other sites
Quote:
 Original post by BenDrummin58woops sorry bout that.. I havn't really used vectors in the way you are using them quite that much. In fact, your whole project looks too over complicated. Not trying to be rude or anything..I just think a lot of the things you did, could have been done in a much more simple way. With that in mind...it's kind of hard to debug somebody elses code, because you aren't familiar with the intentions that the coder had. Basically..the person who made the code is the best person to debug the code. Just keep playing with things going wrong and eventually the answer will hit you. Sometimes..all it takes is a little trial and error. best of luck!

I understand, a lot of it is probably becuase it is broken up into so many functions, and includes AI. push_back just adds whatever is in the arguments to the vector's contaniners (I bet you already knew that, oh well). I'm just perplexed at why I'm getting the error, it seems fine to me.

##### Share on other sites
Yeah I understand...but you better get used to that. lol. So many times I get these dumb errors that don't make ANY sense at all..and I would just sit there explaining to myself over and over again how that should work. Then, after coming back to it the next day, I look and the first thing I see is some stupid mistake..like a logic error, a typo in spelling, forgetting a ;, and what not. Programmer's life is filled with frustration. But don't worry...you'll eventually fix it.

##### Share on other sites
So confusing, whats wrong with this?

vector<int> AllMoves;
AllMoves.push_back(0);
AllMoves.push_back(1);
AllMoves.push_back(2);
AllMoves.push_back(3);
AllMoves.push_back(4);
AllMoves.push_back(5);
AllMoves.push_back(6);
AllMoves.push_back(7);
AllMoves.push_back(8);
srand(time(0));
random_shuffle(AllMoves.begin(), AllMoves.end());

##### Share on other sites
Quote:
 Original post by BenDrummin58Yeah I understand...but you better get used to that. lol. So many times I get these dumb errors that don't make ANY sense at all..and I would just sit there explaining to myself over and over again how that should work. Then, after coming back to it the next day, I look and the first thing I see is some stupid mistake..like a logic error, a typo in spelling, forgetting a ;, and what not. Programmer's life is filled with frustration. But don't worry...you'll eventually fix it.

Haha, yes I've looked at it over and over \8, oh well gotta stay positive cause in two days school is over and I have plenty of time for this! :] Having a dumb error in your code is a lot less frusterating than dying over and over in the same spot of a video game in my opinion.

##### Share on other sites
I think you don't have the correct number of brackets in the function computer move.

Specifically, on the lines

board[move] = Computerturn;            if(IsLegal(board, move))                              if(winner(board) == computer)

You don't have a bracket after the if(ISLegal(board, move)) but before if(winner(board)==computer)

I think that will help a little. Note, you possibly have an extra bracket somewhere else, but not necessarily.

And a tip: next time don't just type the entire game in one go. Write a function, test that it does what you think it does. Then write another and test that it does what you think it does. And so on. This way you won't have so many compiler errors.

##### Share on other sites
Quote:
 Original post by nobodynewsI think you don't have the correct number of brackets in the function computer move.Specifically, on the linesboard[move] = Computerturn; if(IsLegal(board, move)) if(winner(board) == computer)`You don't have a bracket after the if(ISLegal(board, move)) but before if(winner(board)==computer)I think that will help a little. Note, you possibly have an extra bracket somewhere else, but not necessarily.

I love you. That just put my total number or errors down to only THREE!

##### Share on other sites
1 error left, it's that stupid scope error (read above ^).

##### Share on other sites
:( Never mind, acccidentally capitalized the T :P

##### Share on other sites
And just as I get it to compile, I get an error when trying to display the board...

##### Share on other sites
Quote:
 Original post by nobodynewsAnd a tip: next time don't just type the entire game in one go. Write a function, test that it does what you think it does. Then write another and test that it does what you think it does. And so on. This way you won't have so many compiler errors.

Quoted and emboldened for extreme emphasis.

Also, you really, really, REALLY need to fix up your indentation. Make the amount of whitespace at the beginning of the line proportionate to the number of {}-levels in you are. Then when it fails to balance out, it will be much more obvious.

##### Share on other sites
Quote:
Original post by Zahlman
Quote:
 Original post by nobodynewsAnd a tip: next time don't just type the entire game in one go. Write a function, test that it does what you think it does. Then write another and test that it does what you think it does. And so on. This way you won't have so many compiler errors.

Quoted and emboldened for extreme emphasis.

Also, you really, really, REALLY need to fix up your indentation. Make the amount of whitespace at the beginning of the line proportionate to the number of {}-levels in you are. Then when it fails to balance out, it will be much more obvious.

Yes I REALLY need to do that next time. It look as if it won't accept ANY move from the human, and the computer's AI is screwy. The computer thinks it's won after it places one piece, haha. Testing my functions would have cause me alot less trouble.

##### Share on other sites
it's all good... the best part of getting to know programming is learning from your mistakes.

##### Share on other sites

This topic is 4205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628714
• Total Posts
2984357

• 23
• 11
• 10
• 13
• 14