Hey guys I am making a tic tac toe game and it is 90% finished, but I am not
allowed to use classes.
The problem I have is on the computer move. If the computer hit's a sqaure the
player has already chosen, would it be wise to use a recursive step to pick
another square that is empty?
This is the code for a the [0][0] sqaure on the computer move:
Code:
// function to simulate the computer's move
void computerMove ( char brd[][ 3 ], const char *let, const char *cmp ) {
int choosePos = ( 1 + rand() % 9 );
switch ( choosePos ) {
case 1:
{
if ( brd[ 0 ][ 0 ] == *let ) {
}
brd[ 0 ][ 0 ] = *cmp;
}
break;
The code to exexute this would be placed within the "if statement" that
is checking if the player already exisits there. Or instead of recursion would
a true false loop be advisable?
When I compile and run the code as it is I win since it isnt finished .
Any advise appricaited.