From 0e8bf42ddde1f9d8e836c429bf2eefea4ef6295b Mon Sep 17 00:00:00 2001 From: Andreas Koepf Date: Thu, 13 Feb 2025 19:06:20 +0100 Subject: [PATCH] use json formatting for initial state of game-of-life board --- reasoning_gym/games/game_of_life.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/reasoning_gym/games/game_of_life.py b/reasoning_gym/games/game_of_life.py index b77f3fd6..2b5e369b 100644 --- a/reasoning_gym/games/game_of_life.py +++ b/reasoning_gym/games/game_of_life.py @@ -1,7 +1,7 @@ import json from dataclasses import dataclass from random import Random -from typing import Dict, List, Optional, Tuple +from typing import Dict, Optional import cellpylib as cpl @@ -12,8 +12,8 @@ from ..factory import ProceduralDataset, register_dataset class GameOfLifeConfig: """Configuration for sudoku puzzle generation""" - grid_size_x: int = 20 - grid_size_y: int = 20 + grid_size_x: int = 10 + grid_size_y: int = 10 filled_cells: int = 100 # actually a max simulation_steps: int = 1 seed: Optional[int] = None @@ -60,10 +60,15 @@ class GameOfLifeDataset(ProceduralDataset): # Simulate the result to get the answer evolved = cpl.evolve2d( - board, timesteps=self.config.simulation_steps + 1, apply_rule=cpl.game_of_life_rule, memoize="recursive" + board, + timesteps=self.config.simulation_steps + 1, + apply_rule=cpl.game_of_life_rule, + memoize="recursive", ) - board_str = str(board[0]) + rows = [json.dumps(board[0, i].tolist(), separators=(",", ":")) for i in range(board.shape[1])] + board_str = "[" + ", \n ".join(rows) + "]" + final_step = evolved[-1] final_step_list = final_step.tolist() result_str = json.dumps(final_step_list, separators=(",", ":"))