| summaryrefslogtreecommitdiff |
path: root/tonkadur.py
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-08-30 16:14:54 +0200 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-08-30 16:14:54 +0200 |
| commit | 48f780650c7d92c945989b45dc781d415c85a21d (patch) | |
| tree | 623f298e233c01e47e6d6422c120f8df23476d84 /tonkadur.py | |
| parent | b6108592b66cc14573e5614aa5c878b71c6be6cb (diff) | |
Adds user prompts, removes address of player_choice.
Diffstat (limited to 'tonkadur.py')
| -rw-r--r-- | tonkadur.py | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/tonkadur.py b/tonkadur.py index 61e87a8..146bfe4 100644 --- a/tonkadur.py +++ b/tonkadur.py @@ -34,6 +34,7 @@ class Tonkadur: self.allocated_data = 0 self.last_choice_index = -1 self.available_choices = [] + self.memorized_target = [] with open(json_file, 'r') as f: json_content = json.load(f) @@ -209,6 +210,28 @@ class Tonkadur: self.available_choices = [] self.last_choice_index = index + def store_integer (self, value): + current_val = self.memory + + for access in self.memorized_target: + pre_val = current_val + last_access = access + if (access in current_val): + current_val = current_val[access] + + pre_val[last_access] = value + + def store_string (self, value): + current_val = self.memory + + for access in self.memorized_target: + pre_val = current_val + last_access = access + if (access in current_val): + current_val = current_val[access] + + pre_val[last_access] = value + def run (self): while True: #print("\nmemory: " + str(self.memory)) @@ -219,9 +242,7 @@ class Tonkadur: if (instruction_category == "add_choice"): self.available_choices.append( - [ - self.compute(instruction['label']) - ] + self.compute(instruction['label']) ) self.program_counter += 1 elif (instruction_category == "assert"): @@ -308,6 +329,31 @@ class Tonkadur: pre_val[last_access] = result self.program_counter += 1 + elif (instruction_category == "prompt_integer"): + result = dict() + result["category"] = "prompt_integer" + result["min"] = self.compute(instruction['min']) + result["max"] = self.compute(instruction['max']) + result["label"] = self.compute(instruction['label']) + + self.memorized_target = self.compute(instruction['target']) + + self.program_counter += 1 + + return result + + elif (instruction_category == "prompt_string"): + result = dict() + result["category"] = "prompt_string" + result["min"] = self.compute(instruction['min']) + result["max"] = self.compute(instruction['max']) + result["label"] = self.compute(instruction['label']) + + self.memorized_target = self.compute(instruction['target']) + + self.program_counter += 1 + + return result else: print("Unknown Wyrd instruction: \"" + instruction_category + "\"") |


