Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (jogada == 0) {
- //procurar linha e coluna que só tenham jogadas do adversário
- //caso encontre joga nessa linha / coluna
- int ljogada = 0;
- int cjogada = 0;
- for (int c = 1; c < 4; c++) { // verifica se há alguma coluna preenchida só pelo adversário
- cjogada = 0;
- for (int l = 0; l < 7; l = l + 3) {
- if (Lista[l + c] == 2) {
- cjogada = 0;
- break;
- }
- if (Lista[l + c] == 1) {
- cjogada = c;
- }
- }
- if (cjogada == c) {
- break;
- }
- }
- for (int l = 0; l < 7; l = l + 3) { //verifica se ganha em linha
- ljogada = 0;
- for (int c = 1; c < 4; c++) {
- if (Lista[l + c] == 2) {
- ljogada = 0;
- break;
- }
- if (Lista[l + c] == 1) {
- ljogada = l / 3 + 1;
- }
- }
- if (ljogada == l / 3 + 1) {
- break;
- }
- }
- if (ljogada != 0 && cjogada != 0 && Lista[ljogada * 3 - 3 + cjogada] == 0) {
- jogada = ljogada * 3 - 3 + cjogada;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement