new main.cpp
#include "tic.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(time(0));
Board b1('x', 'o');
Board b2('o', 'x');
bool done = false;
int move;
while(!done) {
b1.reset();
while(1) {
cout << "Enter space with numpad: ";
cin >> move;
if(!b1.makeMove(move)) {
cout << "bad move" << endl;
continue;
}
b1.show();
if(b1.checkWin()) {
cout << "x wins!" << endl;
done = true;
break;
}
while(1) {
move = rand() % 9 + 1;
if(!b2.makeMove(move)) {
continue;
}
else
break;
}
b2.show();
if(b2.checkWin()) {
cout << "o wins!" << endl;
done = true;
break;
}
}
}
cout << "Done!" << endl;
return 0;
}
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Last edited by Jessehk; Dec 9th, 2005 at 10:44 PM.
|