From f99dc9481aeb26d6120701034c35295d8134697e Mon Sep 17 00:00:00 2001 From: Quentin18 Date: Fri, 26 Jan 2024 23:33:12 +0100 Subject: [PATCH] style: black format --- src/gymnasium_2048/agents/ntuple/factory.py | 14 ++++++-------- src/gymnasium_2048/agents/ntuple/policy.py | 12 ++++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/gymnasium_2048/agents/ntuple/factory.py b/src/gymnasium_2048/agents/ntuple/factory.py index b211fe5..d288ecc 100644 --- a/src/gymnasium_2048/agents/ntuple/factory.py +++ b/src/gymnasium_2048/agents/ntuple/factory.py @@ -35,14 +35,12 @@ def get_all_rectangles_tuples(state: np.ndarray) -> Sequence[Sequence[int]]: # square for row in range(state.shape[0] - 1): for col in range(state.shape[1] - 1): - tuples.append( - ( - state[row, col], - state[row, col + 1], - state[row + 1, col + 1], - state[row + 1, col], - ) - ) + tuples.append(( + state[row, col], + state[row, col + 1], + state[row + 1, col + 1], + state[row + 1, col], + )) return tuples diff --git a/src/gymnasium_2048/agents/ntuple/policy.py b/src/gymnasium_2048/agents/ntuple/policy.py index c5cafc1..5eac8c9 100644 --- a/src/gymnasium_2048/agents/ntuple/policy.py +++ b/src/gymnasium_2048/agents/ntuple/policy.py @@ -96,9 +96,9 @@ def predict(self, state: np.ndarray) -> int: :param state: The board state. :return: Next action to play. """ - return np.argmax([ - self.evaluate(state=state, action=action) for action in range(4) - ]) + return np.argmax( + [self.evaluate(state=state, action=action) for action in range(4)] + ) @abstractmethod def save(self, path: str | pathlib.Path | io.BufferedIOBase) -> None: @@ -207,9 +207,9 @@ def learn( after_state_tuples = self._get_tuples(state=after_state) after_state_value = self.net.predict(tuples=after_state_tuples) - next_action = np.argmax([ - self.evaluate(state=next_state, action=a) for a in range(4) - ]) + next_action = np.argmax( + [self.evaluate(state=next_state, action=a) for a in range(4)] + ) next_after_state, next_reward, is_legal = TwentyFortyEightEnv.apply_action( board=next_state, action=next_action,