Advertisement
swalter

Desafío Ludico - Juego de la vida

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