From c1859656572f70b2a897f6150285f62d49159f2e Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 26 Feb 2023 12:10:27 -0800 Subject: [PATCH] Lowered timeout and improved act() --- celeste/celeste_ai/celeste.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/celeste/celeste_ai/celeste.py b/celeste/celeste_ai/celeste.py index 0ee166e..d7fdf13 100755 --- a/celeste/celeste_ai/celeste.py +++ b/celeste/celeste_ai/celeste.py @@ -102,7 +102,7 @@ class Celeste: self, pico_path, *, - state_timeout = 30, + state_timeout = 20, cart_name = "hackcel.p8", ): @@ -147,7 +147,7 @@ class Celeste: self._resetting = False # True between a call to .reset() and the first state message from pico. self._keys = {} # Dictionary of "key": bool - def act(self, action: str): + def act(self, action: str | int): """ Specify what keys should be down. This does NOT send key events. Celeste._apply_keys() does that at the right time. @@ -156,6 +156,9 @@ class Celeste: action (str): key name, as in Celeste.action_space """ + if isinstance(action, int): + action = Celeste.action_space[action] + self._keys = {} if action is None: return