| summaryrefslogtreecommitdiff |
path: root/tonkadur.py
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-08-30 02:14:07 +0200 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-08-30 02:14:07 +0200 |
| commit | b6108592b66cc14573e5614aa5c878b71c6be6cb (patch) | |
| tree | e6c262127a79f8142b9e0ebd443ab0af398b0aa8 /tonkadur.py | |
| parent | 1609330b4e4a1ad1e3ed26db75efdab5f9729663 (diff) | |
Changes how choices are handled.
Diffstat (limited to 'tonkadur.py')
| -rw-r--r-- | tonkadur.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tonkadur.py b/tonkadur.py index 0bfe8d6..61e87a8 100644 --- a/tonkadur.py +++ b/tonkadur.py @@ -32,6 +32,7 @@ class Tonkadur: self.code = [] self.program_counter = 0 self.allocated_data = 0 + self.last_choice_index = -1 self.available_choices = [] with open(json_file, 'r') as f: @@ -199,10 +200,14 @@ class Tonkadur: # if (isinstance(target, list)): # print("That's a list.") return target + elif (computation_category == "last_choice_index"): + return self.last_choice_index + else: + print("Unknown Wyrd computation: \"" + computation_category + "\"") - def resolve_choice_to (self, line): + def resolve_choice_to (self, index): self.available_choices = [] - self.program_counter = line + self.last_choice_index = index def run (self): while True: @@ -215,8 +220,7 @@ class Tonkadur: if (instruction_category == "add_choice"): self.available_choices.append( [ - self.compute(instruction['label']), - self.compute(instruction['address']) + self.compute(instruction['label']) ] ) self.program_counter += 1 @@ -275,6 +279,7 @@ class Tonkadur: result = dict() result["category"] = "resolve_choices" result["choices"] = self.available_choices + self.program_counter += 1 return result elif (instruction_category == "set_pc"): @@ -303,4 +308,6 @@ class Tonkadur: pre_val[last_access] = result self.program_counter += 1 + else: + print("Unknown Wyrd instruction: \"" + instruction_category + "\"") |


