";
tobereturned = tobereturned + "";
return tobereturned;
}
int computerMove(int c1, int c2, int c3, int c4,
int c5, int c6, int c7, int c8, int c9){
bool found;
found = true;
while(found){
seed = (1 * seed + 0) % 9;
if(seed < 0) seed = 0 - seed;
seed = seed + 1;
if( (c1>=0) &&
(c2>=0) &&
(c3>=0) &&
(c4>=0) &&
(c5>=0) &&
(c6>=0) &&
(c7>=0) &&
(c8>=0) &&
(c9>=0) ){
found = false;
return 77;
}
if( ((seed==1) && (c1<0)) ||
((seed==2) && (c2<0)) ||
((seed==3) && (c3<0)) ||
((seed==4) && (c4<0)) ||
((seed==5) && (c5<0)) ||
((seed==6) && (c6<0)) ||
((seed==7) && (c7<0)) ||
((seed==8) && (c8<0)) ||
((seed==9) && (c9<0)) ){
found = false;
return (seed);
}
}
return (-1);
}
session startGame(){
int current_selection;
int game_completed;
int winResult, winResult2, current_computer_move;
int c1, c2, c3, c4, c5, c6, c7, c8, c9;
string str;
current_computer_move = -1;
c1 = -1;
c2 = -1;
c3 = -1;
c4 = -1;
c5 = -1;
c6 = -1;
c7 = -1;
c8 = -1;
c9 = -1;
str = "";
current_selection = 0;
game_completed = 20;
show Welcome_screen;
show plug printStr[str2print=createHTML(c1,c2,c3,c4,c5,c6,c7,c8,c9)] receive[current_selection=cell];
while(game_completed == 20){
if(current_selection == 1) c1 = 1;
if(current_selection == 2) c2 = 1;
if(current_selection == 3) c3 = 1;
if(current_selection == 4) c4 = 1;
if(current_selection == 5) c5 = 1;
if(current_selection == 6) c6 = 1;
if(current_selection == 7) c7 = 1;
if(current_selection == 8) c8 = 1;
if(current_selection == 9) c9 = 1;
if( (current_selection >=1) &&
(current_selection <= 9) ){
winResult = checkWin(c1,c2,c3,c4,c5,c6,c7,c8,c9);
if(winResult < 0){
current_computer_move = computerMove(c1,c2,c3,c4,c5,c6,c7,c8,c9);
if(current_computer_move == 1) c1 = 0;
if(current_computer_move == 2) c2 = 0;
if(current_computer_move == 3) c3 = 0;
if(current_computer_move == 4) c4 = 0;
if(current_computer_move == 5) c5 = 0;
if(current_computer_move == 6) c6 = 0;
if(current_computer_move == 7) c7 = 0;
if(current_computer_move == 8) c8 = 0;
if(current_computer_move == 9) c9 = 0;
if(current_computer_move == 77){
no_of_times_draw = no_of_times_draw + 1;
exit plug draw[user=no_of_times_user_won,computer=no_of_times_computer_won,drawn=no_of_times_draw];
}
winResult2 = checkWin(c1,c2,c3,c4,c5,c6,c7,c8,c9);
if(winResult2 < 0){
show plug printStr[str2print=createHTML(c1,c2,c3,c4,c5,c6,c7,c8,c9)] receive[current_selection=cell];
}
else{
game_completed = 19;
if(winResult2 == 0){
no_of_times_computer_won = no_of_times_computer_won + 1;
}
if(winResult2 == 1){
no_of_times_user_won = no_of_times_user_won + 1;
}
exit plug result[id=winResult2,user=no_of_times_user_won,computer=no_of_times_computer_won,drawn=no_of_times_draw,cell1=c1,cell2=c2,cell3=c3,cell4=c4,cell5=c5,cell6=c6,cell7=c7,cell8=c8,cell9=c9];
}
}
else{
game_completed = 19;
if(winResult == 0){
no_of_times_computer_won = no_of_times_computer_won + 1;
}
if(winResult == 1){
no_of_times_user_won = no_of_times_user_won + 1;
}
exit plug result[id=winResult,user=no_of_times_user_won,computer=no_of_times_computer_won,drawn=no_of_times_draw,cell1=c1,cell2=c2,cell3=c3,cell4=c4,cell5=c5,cell6=c6,cell7=c7,cell8=c8,cell9=c9];
}
}
else{
show plug printStr[str2print=createHTML(c1,c2,c3,c4,c5,c6,c7,c8,c9)] receive[current_selection=cell];
}
}
}
}