Hola como estan miren hice un post anteriormente el cual era de hacer un laberinto y poner al lobo y caperucita. El lObo tiene que ir detras de caperucita Roja mas o menos lo tengo avanzado por el momento le s mostrare el codigo.
Y la duda con la que estoy
<?php
//Array que devolverá el laberinto
array(1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), array(1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1), array(1,0,1,0,1,1,1,1,0,1,1,1,1,1,0,1,0,0,1,0,1,0,0,1), array(1,0,1,0,0,0,0,1,0,1,0,0,0,0,0,1,1,0,1,1,1,0,1,1), array(1,0,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,1), array(1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,1,0,1,0,1,0,0,1), array(1,1,1,0,1,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1), array(1,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1), array(1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,1), array(1,0,1,0,1,0,1,1,1,1,1,1,0,1,0,1,0,0,1,0,1,0,0,1), array(1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,1,1), array(1,0,1,0,1,0,1,1,1,1,1,0,1,1,0,0,0,1,0,0,1,0,0,1), array(1,0,0,0,1,0,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1,0,1,1), array(1,0,1,0,0,0,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1), array(1,0,1,1,1,0,0,1,0,0,1,0,0,1,0,1,1,1,1,0,1,1,0,1), array(1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1), array(1,1,1,0,1,1,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,1), array(1,0,1,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,1,0,1,0,1), array(1,0,1,0,1,0,1,1,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,1), array(1,0,0,0,1,0,0,1,0,0,1,0,1,0,1,0,0,0,1,1,0,0,0,1), array(1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,1,0,0,1,1,1,0,1), array(1,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1), array(1,0,1,0,1,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,1), array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) );
/*
Esta función ubica aleatoriamente (o a través del parámetro $p)
la caperusita en el laberinto. Además, guarda estas posiciones en las
variables $qx y $qy
*/
function caperusita(&$array,$p = NULL)
{
global $qx,$qy;
$t[1] = $p[0];
$t[0] = $p[1];
} else {
}
if($array[$t[0]][$t[1]] == 0 && isset($array[$t[0]][$t[1]])) { $array[$t[0]][$t[1]] = 2;
$qx = $t[1];
$qy = $t[0];
return TRUE;
} else {
return caperusita($array);
}
}
La duda con la que estoy es como poder hacer el laberinto de manera randomica.
osea la forma.
//Array que devolverá el laberinto
array(1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), array(1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1), array(1,0,1,0,1,1,1,1,0,1,1,1,1,1,0,1,0,0,1,0,1,0,0,1), array(1,0,1,0,0,0,0,1,0,1,0,0,0,0,0,1,1,0,1,1,1,0,1,1), array(1,0,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,1), array(1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,1,0,1,0,1,0,0,1), array(1,1,1,0,1,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1), array(1,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1), array(1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,1), array(1,0,1,0,1,0,1,1,1,1,1,1,0,1,0,1,0,0,1,0,1,0,0,1), array(1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,1,1), array(1,0,1,0,1,0,1,1,1,1,1,0,1,1,0,0,0,1,0,0,1,0,0,1), array(1,0,0,0,1,0,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1,0,1,1), array(1,0,1,0,0,0,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1), array(1,0,1,1,1,0,0,1,0,0,1,0,0,1,0,1,1,1,1,0,1,1,0,1), array(1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1), array(1,1,1,0,1,1,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,1), array(1,0,1,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,1,0,1,0,1), array(1,0,1,0,1,0,1,1,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,1), array(1,0,0,0,1,0,0,1,0,0,1,0,1,0,1,0,0,0,1,1,0,0,0,1), array(1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,1,0,0,1,1,1,0,1), array(1,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1), array(1,0,1,0,1,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,1), array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) );
La funcion de la caperucita sera casi la misma a la del lobo, lo que quiero es poder darle la opcion a que el lobo lo biusqye de manera propia si n necesirdad de intervencion del usuario ...