include("functions.php");
include("../levels.php");
$parameters_valid = true;
$program_valid = 0;
if ( isset( $_GET['level'] ) && !empty( $_GET['level'] )){
if(is_numeric( $_GET['level'] )){
$level = $_GET['level'];
}
else{
// echo("level value invalid
");
$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
");
// }
?>
"); // 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,
Program Data:\nUsed Instruction: $instruction_counter\n"); echo("Program: "); print_r($program); echo(""); echo("
Level Configuration: "; print_r($level_configuration); echo(""); 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("
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-CodeLaden...
|