Exemple #1
0
int error_check( int x, int y, TicTacToe board1 ) {
    
    int err = 0 ;
    
    err = board1.checkBoundry( x, y ) ;
    
    if( err ==  2 ) {
        cout << "ERROR : The X coordinate you specified is out of the board." << endl ;
        return 1 ;
    }
    if( err == 3 ) {
        cout << "ERROR : The Y coordinate you specified is out of the board." << endl ;
        return 2 ;
    }
    
    else {
        
        err = board1.checkSpace( x, y ) ; //Check to see if a move is already there

        if( err == 1 ) {
            cout << "ERROR : There is already a move there." ;
            return 3 ;
        }
        
    }
    
    return 0 ; 
    
}
Exemple #2
0
void comp_move_easy( int &x, int &y, TicTacToe board1 ) {

    int err ;

    srand( time( NULL ) ) ;
    while( 1 ) {
        x = 1 + ( rand() % 3 ) ;
        y = 1 + ( rand() % 3 ) ;
        err = board1.checkBoundry( x, y ) ;
        if( err == 0 ) break ; 
    }
    
    return ; 

}