Repeat the same level until success

master
BodgeMaster 2022-12-23 12:56:57 +01:00
parent e814cfe21d
commit f8e316bdc4
1 changed files with 7 additions and 2 deletions

View File

@ -516,7 +516,11 @@ def setup_and_run_task(start_field, start_position, start_heading, text, allowed
print("\n"+text) print("\n"+text)
print("\nAllowed commands: "+", ".join(allowed_commands)) print("\nAllowed commands: "+", ".join(allowed_commands))
print("\nAvailable conditions: "+", ".join(allowed_conditions)) print("\nAvailable conditions: "+", ".join(allowed_conditions))
print(evaluate_parser_result(parse_code(input("\nCode: "), allowed_commands, allowed_conditions))) result = evaluate_parser_result(parse_code(input("\nCode: "), allowed_commands, allowed_conditions))
print(result)
if result=="Success!":
return True
return False
if __name__ == "__main__": if __name__ == "__main__":
import sys, os, json import sys, os, json
@ -568,7 +572,8 @@ if __name__ == "__main__":
else: else:
print("Unknown start heading!") print("Unknown start heading!")
sys.exit(1) sys.exit(1)
setup_and_run_task(level_data["field"], level_data["start position"], cursor_start, level_data["text"], level_data["allowed commands"], level_data["allowed conditions"]) while not setup_and_run_task(level_data["field"].copy(), level_data["start position"].copy(), cursor_start, level_data["text"], level_data["allowed commands"].copy(), level_data["allowed conditions"].copy()):
time.sleep(3)
if single_file_mode: if single_file_mode:
break break