previous

page 12

next
computer()
...
// no good move found - make id_loser move & lose
do_x(id_loser);
check();
show_result();
g_message_el.textContent='you win';
}
square_clicked()
function square_clicked(el) {
if (g_player && g_squares[el.id]==0) {
g_player=false;
do_x(el.id);
if (check()) {
show_result();
g_message_el.textContent='computer wins';
} else {
setTimeout(computer,2000);
}
}
}
previous
next