File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
src/gymnasium_2048/agents/ntuple Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -46,12 +46,14 @@ def read_metrics(filename: str) -> pd.DataFrame:
46
46
line ,
47
47
).groups ()
48
48
49
- data .append ({
50
- "episode" : int (episode ),
51
- "winning_rate" : float (winning_rate ),
52
- "mean_score" : float (mean_score ),
53
- "max_tile" : int (max_tile ),
54
- })
49
+ data .append (
50
+ {
51
+ "episode" : int (episode ),
52
+ "winning_rate" : float (winning_rate ),
53
+ "mean_score" : float (mean_score ),
54
+ "max_tile" : int (max_tile ),
55
+ }
56
+ )
55
57
56
58
return pd .DataFrame (data )
57
59
Original file line number Diff line number Diff line change @@ -96,9 +96,9 @@ def predict(self, state: np.ndarray) -> int:
96
96
:param state: The board state.
97
97
:return: Next action to play.
98
98
"""
99
- return np .argmax ([
100
- self .evaluate (state = state , action = action ) for action in range (4 )
101
- ] )
99
+ return np .argmax (
100
+ [ self .evaluate (state = state , action = action ) for action in range (4 )]
101
+ )
102
102
103
103
@abstractmethod
104
104
def save (self , path : str | pathlib .Path | io .BufferedIOBase ) -> None :
@@ -207,9 +207,9 @@ def learn(
207
207
after_state_tuples = self ._get_tuples (state = after_state )
208
208
after_state_value = self .net .predict (tuples = after_state_tuples )
209
209
210
- next_action = np .argmax ([
211
- self .evaluate (state = next_state , action = a ) for a in range (4 )
212
- ] )
210
+ next_action = np .argmax (
211
+ [ self .evaluate (state = next_state , action = a ) for a in range (4 )]
212
+ )
213
213
next_after_state , next_reward , is_legal = TwentyFortyEightEnv .apply_action (
214
214
board = next_state ,
215
215
action = next_action ,
You can’t perform that action at this time.
0 commit comments