Advertisement
swalter

Desafío Ludico - Juego de la vida

Oct 15th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Inicializamos los valores al comienzo del juego
  2. $natalidad=$mortalidad=$sinCambios=0;
  3.  
  4. // Generamos las cordenadas X e Y al azar para el inicio del juego
  5. // Tablero de 6 x 6 celdas
  6.  
  7. $x=rand(0, 6); $y=rand(0, 6);
  8.  
  9. // Generamos al azar si la celda esta viva (1) o Muerta (0) al inicio del juego
  10.  
  11. $arrayTablero[$x][$y] = rand(0, 1);
  12.  
  13. // continua el desarrollo del codigo donde ya comienza el juego
  14.  
  15. if($n < 2){
  16. $arrayTablero[$x][$y] = 0;
  17. $mortalidad++;
  18.  
  19. }
  20.  
  21. if($n > 3){
  22. $arrayTablero[$x][$y] = 0;
  23. $mortalidad++;
  24. }
  25.  
  26. if($n == 3){
  27. $arrayTablero[$x][$y] = 1;
  28. $natalidad++;
  29. }
  30.  
  31. if($n == 2){
  32. $sinCambios++;
  33. // no se modifica
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement