Ejemplo n.º 1
0
function __autoload($class_name)
{
    include 'classes/' . $class_name . '.php';
}
//If valid minimum and maximums have been given then use them, if not just use the default 1-9
if (isset($_POST['min']) && isset($_POST['max']) && $_POST['min'] < $_POST['max']) {
    $stb = new ShutTheBox(null, $_POST['min'], $_POST['max']);
} else {
    $stb = new ShutTheBox();
}
//Get the turns, iterate through them and make the moves
if (isset($_POST['dice']) && is_array($_POST['dice'])) {
    $turns = $_POST['dice'];
    //print_r($turns);
    foreach ($turns as $t) {
        $stb->takeTurn($t);
    }
}
//If the root is marked as successful then a root to success has been found
if ($stb->getSuccess()) {
    echo '<h2>Complete</h2>';
    echo '<p>Here are the moves you could have made:</p><hr>';
    $next = $stb->next();
    $min = $stb->min;
    $max = $stb->max;
    //Display the beginning state:
    echo '<div class="tiles">';
    for ($i = $min; $i <= $max; $i++) {
        echo '<div class="tile available"><p>';
        echo "{$i}</p></div>";
    }