"); $level = 1; $parameters_valid = false; } } else{ //no level given $level = 1; } if ( isset( $_POST['asm'] ) && !empty( $_POST['asm'] )){ $asm = $_POST['asm']; } else{ // echo("asm invalid
"); $parameters_valid = false; $asm = ""; } $level_configuration_function = "level_" . $level . "_configuration"; //build function name, see http://php.net/manual/de/functions.variable-functions.php $level_description_function = ""; $level_test_function = ""; if(is_callable($level_configuration_function)) { // The function does not exists $level_description_function = "level_" . $level . "_description"; //build function name, see http://php.net/manual/de/functions.variable-functions.php $level_test_function = "level_" . $level . "_test"; //build function name, see http://php.net/manual/de/functions.variable-functions.php } else{ // echo("level $level_configuration_function unknown
"); $parameters_valid = false; } // if($parameters_valid == true){ //parameters are ok, level is known list($title, $description, $example, $criteria, $passcode) = $level_description_function(); // call function level_*_description() // echo("$title, $description, $example, $criteria, $passcode
"); // } ?> <? echo("$GC_ID: $GC_NAME"); ?> - Programm ausführen (Level <? echo("$level: \"$title\""); ?>)

- Programm ausführen (Level )

< Zurück zum Code Editor
"); // echo("$title, $description, $example, $criteria
"); // $parameters_valid = true; // echo("Passcode: $passcode, given: " . $_GET['passcode'] . "
"); if($passcode != $_GET['passcode']){ //passcode is wrong, level not allowed ?>

Der Passcode für das angegebene Level ist ungültig!
Versuchs mal mit Level 1.

Kein Programm-Code übergeben!

"); ?>

Das angegebene Level existiert nicht!
Versuchs mal mit Level 1.

"); // print_r($arr_asm); // echo(""); array_walk($arr_asm, 'cleanup_asm_array'); $arr_asm = array_slice(array_diff($arr_asm, array('')), 0); //Remove all empty lines from array // echo("
");
    //     print_r($arr_asm);
    //     echo("
"); list($program_valid, $program, $program_summary, $instruction_counter, $labels_counter, $comments_counter) = init_program($arr_asm, $level, $passcode); // if($program_valid != true){$program_valid = 0; } // echo("instruction_counter: $instruction_counter,
"); // echo("program_valid: \"$program_valid\"
"); $debug = false; if($program[0]['cmd'] == 'comment'){ if($program[0]['comment'] == '--debug'){ echo("

DEBUG Modus

"); $debug = true; } } if($debug == true){ echo("
Program Data:\nUsed Instruction: $instruction_counter\n");
            echo("Program: ");
            print_r($program);
            echo("
"); echo("
"); } /*********************************************************** * Initialize the level and test it with several random inputs ***********************************************************/ // list($inbox_size, $max_allowed_steps, $maximum_allowed_instruction, $hand, $data_registers, $test_runs, $reward, $show_outbox_as_coordinate) = $level_configuration_function(); // call function level_*_configuration() $level_configuration = $level_configuration_function(); // call function level_*_configuration() if($debug == true){ echo "
Level Configuration: ";
            print_r($level_configuration);
            echo("
"); echo("
"); } // echo("Reward: $reward
"); // list($program_outcome, $inbox, $expected_outbox, $outbox, $hand, $data_registers, $effectively_used_steps, $max_used_steps) = // $level_test_function($program, $max_allowed_steps, $inbox_size, $hand, $data_registers, $test_runs); // call function level_*_test() /*********************************************************** * Test the program with many iterations ***********************************************************/ if($debug == true){ echo "
Testing program with many iterations...
"; } list($program_outcome, $inbox, $expected_outbox, $average_effectively_used_steps, $max_used_steps, $program_quality) = test_program_with_iterations($program, $level_configuration); if($debug == true){ echo "
Level Status: $program_outcome ($program_quality)\n";
            echo("Run iterations: " . $level_configuration["test_runs"] . " (level setting)\n");
            echo("Average effectively used steps: $average_effectively_used_steps\n");
            echo("Maximum used steps: $max_used_steps\n");
            echo("Max allowed steps: " . $level_configuration["max_allowed_steps"] . " (level setting)\n");
            echo("
"); echo("
"); } /*********************************************************** * Test the program for the specific level with the shown inputs ***********************************************************/ if($debug == true){ echo "
Testing the program with the shown inputs...
"; } // list($program_outcome, $effectively_used_steps) = test_program($program, $inbox, $expected_outbox, $hand, $data_registers, $max_allowed_steps); list($program_outcome, $effectively_used_steps) = test_program($program, $inbox, $expected_outbox, $level_configuration["hand"], $level_configuration["data_registers"], $level_configuration["max_allowed_steps"]); if($debug == true){ echo "
Level Status: $program_outcome\n";
            echo("Inbox: ");
            print_r($inbox);
            echo("Expected Outbox: ");
            print_r($expected_outbox);
            echo("
"); echo("
"); } ?>

Sandbox

Program Steps: "); foreach($step_boxes as $step){ echo("$step, "); }; echo(""); } ?>
Initialisiere CPU...

Formatierter Programm-Code

Laden...