Created
October 30, 2012 16:18
-
-
Save mariucagl/3981262 to your computer and use it in GitHub Desktop.
Tres en Raya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tres en ralla | |
var a1 = [0,0,0] | |
var a2 = [0,0,0] | |
var a3 = [0,0,0] | |
var tablero = [a1,a2,a3] | |
/* | |
A continuación a1 (sus posibles) | |
*/ | |
tablero[0][0]; | |
tablero[0][1]; | |
tablero[0][2]; | |
/* | |
A continuación a2 (sus posibles) | |
*/ | |
tablero[1][0]; | |
tablero[1][1]; | |
tablero[1][2]; | |
/* | |
A continuación a3 (sus posibles) | |
*/ | |
tablero[2][0]; | |
tablero[2][1]; | |
tablero[2][2]; | |
function comprobarTablero(pos){ | |
si a1 esta completo = tres en raya | |
si a2 esta completo = tres en raya | |
si a3 esta completo = tres en raya | |
si tablero[0][0]; tablero[1][0]; tablero[2][0]; = tres en raya | |
si tablero[0][1]; tablero[1][1]; tablero[2][1]; = tres en raya | |
si tablero[0][2]; tablero[1][2]; tablero[2][2]; = tres en raya | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Corrección: Aquí pongo la función de comprobar tablero pero con código:
var a1 = [0,0,0]
var a2 = [0,0,0]
var a3 = [0,0,0]
var tablero = [a1,a2,a3]
/*
A continuación a1 (sus posibles)
/
tablero[0][0];
tablero[0][1];
tablero[0][2];
/
A continuación a2 (sus posibles)
/
tablero[1][0];
tablero[1][1];
tablero[1][2];
/
A continuación a3 (sus posibles)
*/
tablero[2][0];
tablero[2][1];
tablero[2][2];
function comprobarTablero(){
if(a1 == "x"){
alert ("tres en raya")
reset()
}
else if(a2 == "x"){
alert ("tres en raya")
reset()
}
else if(a3 == "x"){
alert ("tres en raya")
reset()
}
else if(tablero[0][0] == "x" && tablero[1][0] == "x" && tablero[2][0] == "x"){
alert ("tres en raya")
reset()
}
else if(tablero[0][1] == "x" && tablero[1][1] == "x" && tablero[2][1] == "x"){
alert ("tres en raya")
reset()
}
else if(tablero[0][2] == "x" && tablero[1][2] == "x" && tablero[2][2] == "x"){
alert ("tres en raya")
reset()
}
}