From 87fdb8c1903f6fb48b6efe5e6fb1a2ffb0c5bd27 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Thu, 21 Nov 2024 14:18:34 +0100 Subject: [PATCH] InteractiveDecisionMaker uses alphabet characters to identify choices (less confusing, because model elements often already include numbers) --- util/simulator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/simulator.py b/util/simulator.py index b347de2..4949a3f 100644 --- a/util/simulator.py +++ b/util/simulator.py @@ -42,7 +42,7 @@ class InteractiveDecisionMaker(DecisionMaker): def __call__(self, actions): arr = [] for i, (key, result) in enumerate(actions): - print(f" {i}. {key}") + print(f" {chr(97+i)}. {key}") arr.append(result) if len(arr) == 0: return @@ -53,7 +53,7 @@ class InteractiveDecisionMaker(DecisionMaker): sys.stdout.write(f"{self.msg} ") try: raw = input() - choice = int(raw) # may raise ValueError + choice = int(ord(raw)-97) # may raise ValueError if choice >= 0 and choice < len(arr): return arr[choice] except ValueError: