Skip to content

Migrate text_based_game: sudoku and game agent features - #30

Merged
banghuaz-nvidia merged 3 commits into
mainfrom
text_based_game-github
Sep 18, 2025
Merged

banghuaz-nvidia merged 3 commits into
mainfrom
text_based_game-github

Conversation

@RahulSChand

Copy link
Copy Markdown
Contributor

Details

This is a resource server for sudoku text based game. The correctness is checked programtically. The reward is returned at each step (each call of the make_move function. The final reward is the sum)

Dataset: The dataset is proceduraly generated. But for it to be compatible with current trajectory generation framework. We have a simple_sudoku.jsonl and a script (steps below) that can be used to create a jsonl to use for trajectory generation. This would be changed later

Steps to run

  1. Download reference dataset
ng_download_dataset_to_gitlab \
    +dataset_name=simple_sudoku \
    +version=0.0.2 \
    +artifact_fpath=simple_sudoku.jsonl \
    +output_fpath=data/simple_sudoku.jsonl
  1. Create a larger jsonl (the reference dataset just has 1 data point as reference for how the system prompt, tool definition should look like). Below generates 5 examples. Currently the game parameters , board size & number of clues are selected randomly in a reasonable range (4 & 9 for board size and btw (6,12) for board of sizse 4 and (16, 48) for board size 9. In the future we could replace this with a parameter of how tough we want the game)

Run below from the simple_sudoku/ folder

python generate_sudoku_jsonl.py ../../data/simple_sudoku.jsonl 5 ../../data/sudoku_batch.jsonl
  1. Start the servers (this starts the simple_game_agent, the model server & the sudkoku environment server)
ng_run "+config_paths=[responses_api_agents/simple_game_agent/configs/simple_game_agent.yaml,responses_api_models/openai_model/configs/openai_model.yaml,resources_servers/simple_sudoku/configs/simple_sudoku.yaml]" +simple_game_agent.responses_api_agents.simple_game_agent.resources_server.name=simple_sudoku
  1. Start trajectory collection
ng_collect_traj +agent_name=simple_game_agent +input_jsonl_fpath=data/sudoku_batch.jsonl +output_jsonl_fpath=results/sudoku_output_NEWLOGIC.jsonl

Example Rollouts:

{"responses_create_params": {"input": [], "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}]}, "response": {"id": "resp_68bd93aa0e9081948ee1fb98147b354701b662383935ba9f", "created_at": 1757254570.0, "error": null, "incomplete_details": null, "instructions": null, "metadata": {}, "model": "gpt-4.1-2025-04-14", "object": "response", "output": [{"arguments": "{\"row\":2,\"col\":3,\"number\":3}", "call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "name": "make_move", "type": "function_call", "id": "fc_68bd93a1faec8194b1669db531b87b8a039ed859b3babbe5", "status": "completed"}, {"call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "output": "{\"success\": false, \"message\": \"Incorrect move: R2 C3 = 3 violates Sudoku rules\", \"game_state\": {\"current_board\": [[0, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 1, \"correct_moves\": 0}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  .  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":1,\"number\":1}", "call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "name": "make_move", "type": "function_call", "id": "fc_68bd93a31d648193b06f9923513b16640b983aa011463905", "status": "completed"}, {"call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "output": "{\"success\": true, \"message\": \"Correct move! R1 C1 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 2, \"correct_moves\": 1}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":4,\"number\":3}", "call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "name": "make_move", "type": "function_call", "id": "fc_68bd93a44ac081978ee4664c6853523e0e28ca231f6afdf1", "status": "completed"}, {"call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "output": "{\"success\": true, \"message\": \"Correct move! R1 C4 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 3, \"correct_moves\": 2}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":1,\"number\":2}", "call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "name": "make_move", "type": "function_call", "id": "fc_68bd93a5838c8196b7ac194f34837bfb039cf8ecc424db03", "status": "completed"}, {"call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "output": "{\"success\": true, \"message\": \"Correct move! R2 C1 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 4, \"correct_moves\": 3}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":2,\"number\":3}", "call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a6908c8194962f9d783ef9c08405b4c0e16f7cb6be", "status": "completed"}, {"call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C2 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 5, \"correct_moves\": 4}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":3,\"number\":4}", "call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a780408197a8f194c0c7253d3e07d834853ce8c529", "status": "completed"}, {"call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C3 = 4\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 6, \"correct_moves\": 5}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":3,\"col\":4,\"number\":2}", "call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "name": "make_move", "type": "function_call", "id": "fc_68bd93a895148197bfb733d4c5af173f0db6c67fa5f6bb70", "status": "completed"}, {"call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "output": "{\"success\": true, \"message\": \"Correct move! R3 C4 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 7, \"correct_moves\": 6}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":3,\"number\":1}", "call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "name": "make_move", "type": "function_call", "id": "fc_68bd93a992a88193a5a0bf428d294140050e29fd449a66b6", "status": "completed"}, {"call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "output": "{\"success\": true, \"message\": \"Correct move! R4 C3 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 8, \"correct_moves\": 7}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":4,\"number\":4}", "call_id": "call_FAcCh4KDrE657ryKXNgZL695", "name": "make_move", "type": "function_call", "id": "fc_68bd93ab49f481949fa445b5d6ad069501b662383935ba9f", "status": "completed"}, {"call_id": "call_FAcCh4KDrE657ryKXNgZL695", "output": "{\"success\": true, \"message\": \"Correct move! R4 C4 = 4. Congratulations! Puzzle completed!\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 9, \"correct_moves\": 8}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  4\", \"is_complete\": true, \"move_reward\": 1.0}", "type": "function_call_output", "id": null, "status": null}], "parallel_tool_calls": false, "temperature": 1.0, "tool_choice": "auto", "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}], "top_p": 1.0, "background": false, "max_output_tokens": null, "max_tool_calls": 1, "previous_response_id": null, "prompt": null, "reasoning": {"effort": null, "generate_summary": null, "summary": null}, "service_tier": "default", "status": "completed", "text": {"format": {"type": "text"}, "verbosity": "medium"}, "top_logprobs": 0, "truncation": "disabled", "usage": {"input_tokens": 1103, "input_tokens_details": {"cached_tokens": 0}, "output_tokens": 23, "output_tokens_details": {"reasoning_tokens": 0}, "total_tokens": 1126}, "user": null, "prompt_cache_key": null, "safety_identifier": null, "store": true, "input": [{"role": "user", "type": "message", "content": "You are playing a simple version of Sudoku.\nEach row is numbered from 1 to 4, and each column is also numbered from 1 to 4.\nEmpty cells are represented by '.', and pre-filled cells contain digits from 1 to 4.\n\nYour objective is to fill the empty cells in the 4x4 grid with digits from 1 to 4 such that:\n1. Each row contains all digits from 1 to 4 without repetition.\n2. Each column contains all digits from 1 to 4 without repetition.\n3. Each 2x2 subgrid contains all digits from 1 to 4 without repetition.\n\nRules and Instructions:\n1. **Do not overwrite** the initial numbers provided in the grid.\n2. **Only fill** empty cells represented by '.'.\n3. You must respond with the format '\\boxed{row column number}', e.g. \\boxed{1 1 5}.\n4. **Ensure** that your move does not violate Sudoku rules. Invalid moves will result in penalties.\nUse the make_move function to submit your moves. Good luck!\n\n\n\n   C1 C2   C3 C4  \nR1  .  4 |  2  .\nR2  .  . |  .  1\n   - - - - - - \nR3  4  1 |  3  .\nR4  3  2 |  .  ."}]}, "reward": 1.0, "total_moves": 9, "is_complete": true}

@copy-pr-bot

copy-pr-bot Bot commented Sep 9, 2025

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@banghuaz-nvidia

Copy link
Copy Markdown
Contributor

Thank you Rahul for moving these! Could you please fix the failed checks for all the PRs you submitted there?

@RahulSChand
RahulSChand force-pushed the text_based_game-github branch from 0b47a6a to 0622a32 Compare September 17, 2025 12:00
@RahulSChand
RahulSChand force-pushed the text_based_game-github branch from 0dd139d to 162b6df Compare September 17, 2025 12:14
@banghuaz-nvidia

Copy link
Copy Markdown
Contributor

Thanks! Do you know why this test failed?

Traceback (most recent call last):
  File "/home/runner/work/Gym/Gym/.venv/bin/ng_test_all", line 10, in <module>
    sys.exit(test_all())
             ^^^^^^^^^^
  File "/home/runner/work/Gym/Gym/nemo_gym/cli.py", line 451, in test_all
    len(candidate_dir_paths) == len(dir_paths)
AssertionError: Mismatch on the number of total modules found (18) and the number of actual modules tested (17)!

Also could you please check the other 2 PRs? I think there're still a few failures there.

@RahulSChand

RahulSChand commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor Author

Thanks! Do you know why this test failed?

Traceback (most recent call last):
  File "/home/runner/work/Gym/Gym/.venv/bin/ng_test_all", line 10, in <module>
    sys.exit(test_all())
             ^^^^^^^^^^
  File "/home/runner/work/Gym/Gym/nemo_gym/cli.py", line 451, in test_all
    len(candidate_dir_paths) == len(dir_paths)
AssertionError: Mismatch on the number of total modules found (18) and the number of actual modules tested (17)!

Also could you please check the other 2 PRs? I think there're still a few failures there.

Yeah, this test failed because all new resource_servers now require a data/ folder with the jsonl, trajectory, metrics in it. I am planning to add it, but before that I have to refactor it one more time since Yesterday I had a discussion with Brian and he wants to move as many resource servers to simple_agent as possible. So similar to this PR #44 I have to remove simple_game_agent and use the initialization logic (that is to get the initial game state) like done here: #32 (using seed_session)

@banghuaz-nvidia
banghuaz-nvidia merged commit 8a17b32 into main Sep 18, 2025
@banghuaz-nvidia
banghuaz-nvidia deleted the text_based_game-github branch September 18, 2025 22:23
bxyu-nvidia added a commit that referenced this pull request Sep 18, 2025
bxyu-nvidia added a commit that referenced this pull request Sep 18, 2025
bxyu-nvidia added a commit that referenced this pull request Sep 18, 2025
abhibha-nvidia pushed a commit that referenced this pull request Sep 28, 2025
## Details

This is a resource server for sudoku text based game. The correctness is
checked programtically. The reward is returned at each step (each call
of the `make_move` function. The final reward is the sum)

**Dataset**: The dataset is proceduraly generated. But for it to be
compatible with current trajectory generation framework. We have a
`simple_sudoku.jsonl` and a script (steps below) that can be used to
create a jsonl to use for trajectory generation. This would be changed
later

## Steps to run

1. Download reference dataset

```
ng_download_dataset_to_gitlab \
    +dataset_name=simple_sudoku \
    +version=0.0.2 \
    +artifact_fpath=simple_sudoku.jsonl \
    +output_fpath=data/simple_sudoku.jsonl
```

2. Create a larger jsonl (the reference dataset just has 1 data point as
reference for how the system prompt, tool definition should look like).
Below generates 5 examples. Currently the game parameters , board size &
number of clues are selected randomly in a reasonable range (4 & 9 for
board size and btw (6,12) for board of sizse 4 and (16, 48) for board
size 9. In the future we could replace this with a parameter of how
tough we want the game)

Run below from the `simple_sudoku/` folder
```
python generate_sudoku_jsonl.py ../../data/simple_sudoku.jsonl 5 ../../data/sudoku_batch.jsonl
```

2. Start the servers (this starts the simple_game_agent, the model
server & the sudkoku environment server)

```
ng_run "+config_paths=[responses_api_agents/simple_game_agent/configs/simple_game_agent.yaml,responses_api_models/openai_model/configs/openai_model.yaml,resources_servers/simple_sudoku/configs/simple_sudoku.yaml]" +simple_game_agent.responses_api_agents.simple_game_agent.resources_server.name=simple_sudoku
```

3. Start trajectory collection

```
ng_collect_traj +agent_name=simple_game_agent +input_jsonl_fpath=data/sudoku_batch.jsonl +output_jsonl_fpath=results/sudoku_output_NEWLOGIC.jsonl
```

---

**Example Rollouts**:

```
{"responses_create_params": {"input": [], "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}]}, "response": {"id": "resp_68bd93aa0e9081948ee1fb98147b354701b662383935ba9f", "created_at": 1757254570.0, "error": null, "incomplete_details": null, "instructions": null, "metadata": {}, "model": "gpt-4.1-2025-04-14", "object": "response", "output": [{"arguments": "{\"row\":2,\"col\":3,\"number\":3}", "call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "name": "make_move", "type": "function_call", "id": "fc_68bd93a1faec8194b1669db531b87b8a039ed859b3babbe5", "status": "completed"}, {"call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "output": "{\"success\": false, \"message\": \"Incorrect move: R2 C3 = 3 violates Sudoku rules\", \"game_state\": {\"current_board\": [[0, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 1, \"correct_moves\": 0}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  .  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":1,\"number\":1}", "call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "name": "make_move", "type": "function_call", "id": "fc_68bd93a31d648193b06f9923513b16640b983aa011463905", "status": "completed"}, {"call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "output": "{\"success\": true, \"message\": \"Correct move! R1 C1 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 2, \"correct_moves\": 1}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":4,\"number\":3}", "call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "name": "make_move", "type": "function_call", "id": "fc_68bd93a44ac081978ee4664c6853523e0e28ca231f6afdf1", "status": "completed"}, {"call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "output": "{\"success\": true, \"message\": \"Correct move! R1 C4 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 3, \"correct_moves\": 2}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":1,\"number\":2}", "call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "name": "make_move", "type": "function_call", "id": "fc_68bd93a5838c8196b7ac194f34837bfb039cf8ecc424db03", "status": "completed"}, {"call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "output": "{\"success\": true, \"message\": \"Correct move! R2 C1 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 4, \"correct_moves\": 3}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":2,\"number\":3}", "call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a6908c8194962f9d783ef9c08405b4c0e16f7cb6be", "status": "completed"}, {"call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C2 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 5, \"correct_moves\": 4}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":3,\"number\":4}", "call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a780408197a8f194c0c7253d3e07d834853ce8c529", "status": "completed"}, {"call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C3 = 4\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 6, \"correct_moves\": 5}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":3,\"col\":4,\"number\":2}", "call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "name": "make_move", "type": "function_call", "id": "fc_68bd93a895148197bfb733d4c5af173f0db6c67fa5f6bb70", "status": "completed"}, {"call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "output": "{\"success\": true, \"message\": \"Correct move! R3 C4 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 7, \"correct_moves\": 6}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":3,\"number\":1}", "call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "name": "make_move", "type": "function_call", "id": "fc_68bd93a992a88193a5a0bf428d294140050e29fd449a66b6", "status": "completed"}, {"call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "output": "{\"success\": true, \"message\": \"Correct move! R4 C3 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 8, \"correct_moves\": 7}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":4,\"number\":4}", "call_id": "call_FAcCh4KDrE657ryKXNgZL695", "name": "make_move", "type": "function_call", "id": "fc_68bd93ab49f481949fa445b5d6ad069501b662383935ba9f", "status": "completed"}, {"call_id": "call_FAcCh4KDrE657ryKXNgZL695", "output": "{\"success\": true, \"message\": \"Correct move! R4 C4 = 4. Congratulations! Puzzle completed!\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 9, \"correct_moves\": 8}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  4\", \"is_complete\": true, \"move_reward\": 1.0}", "type": "function_call_output", "id": null, "status": null}], "parallel_tool_calls": false, "temperature": 1.0, "tool_choice": "auto", "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}], "top_p": 1.0, "background": false, "max_output_tokens": null, "max_tool_calls": 1, "previous_response_id": null, "prompt": null, "reasoning": {"effort": null, "generate_summary": null, "summary": null}, "service_tier": "default", "status": "completed", "text": {"format": {"type": "text"}, "verbosity": "medium"}, "top_logprobs": 0, "truncation": "disabled", "usage": {"input_tokens": 1103, "input_tokens_details": {"cached_tokens": 0}, "output_tokens": 23, "output_tokens_details": {"reasoning_tokens": 0}, "total_tokens": 1126}, "user": null, "prompt_cache_key": null, "safety_identifier": null, "store": true, "input": [{"role": "user", "type": "message", "content": "You are playing a simple version of Sudoku.\nEach row is numbered from 1 to 4, and each column is also numbered from 1 to 4.\nEmpty cells are represented by '.', and pre-filled cells contain digits from 1 to 4.\n\nYour objective is to fill the empty cells in the 4x4 grid with digits from 1 to 4 such that:\n1. Each row contains all digits from 1 to 4 without repetition.\n2. Each column contains all digits from 1 to 4 without repetition.\n3. Each 2x2 subgrid contains all digits from 1 to 4 without repetition.\n\nRules and Instructions:\n1. **Do not overwrite** the initial numbers provided in the grid.\n2. **Only fill** empty cells represented by '.'.\n3. You must respond with the format '\\boxed{row column number}', e.g. \\boxed{1 1 5}.\n4. **Ensure** that your move does not violate Sudoku rules. Invalid moves will result in penalties.\nUse the make_move function to submit your moves. Good luck!\n\n\n\n   C1 C2   C3 C4  \nR1  .  4 |  2  .\nR2  .  . |  .  1\n   - - - - - - \nR3  4  1 |  3  .\nR4  3  2 |  .  ."}]}, "reward": 1.0, "total_moves": 9, "is_complete": true}
```
---

---------

Signed-off-by: Rahul Chand <[email protected]>
Signed-off-by: Abhibha Gupta <[email protected]>
abhibha-nvidia pushed a commit that referenced this pull request Sep 28, 2025
abhibha-nvidia pushed a commit that referenced this pull request Sep 29, 2025
## Details

This is a resource server for sudoku text based game. The correctness is
checked programtically. The reward is returned at each step (each call
of the `make_move` function. The final reward is the sum)

**Dataset**: The dataset is proceduraly generated. But for it to be
compatible with current trajectory generation framework. We have a
`simple_sudoku.jsonl` and a script (steps below) that can be used to
create a jsonl to use for trajectory generation. This would be changed
later

## Steps to run

1. Download reference dataset

```
ng_download_dataset_to_gitlab \
    +dataset_name=simple_sudoku \
    +version=0.0.2 \
    +artifact_fpath=simple_sudoku.jsonl \
    +output_fpath=data/simple_sudoku.jsonl
```

2. Create a larger jsonl (the reference dataset just has 1 data point as
reference for how the system prompt, tool definition should look like).
Below generates 5 examples. Currently the game parameters , board size &
number of clues are selected randomly in a reasonable range (4 & 9 for
board size and btw (6,12) for board of sizse 4 and (16, 48) for board
size 9. In the future we could replace this with a parameter of how
tough we want the game)

Run below from the `simple_sudoku/` folder
```
python generate_sudoku_jsonl.py ../../data/simple_sudoku.jsonl 5 ../../data/sudoku_batch.jsonl
```

2. Start the servers (this starts the simple_game_agent, the model
server & the sudkoku environment server)

```
ng_run "+config_paths=[responses_api_agents/simple_game_agent/configs/simple_game_agent.yaml,responses_api_models/openai_model/configs/openai_model.yaml,resources_servers/simple_sudoku/configs/simple_sudoku.yaml]" +simple_game_agent.responses_api_agents.simple_game_agent.resources_server.name=simple_sudoku
```

3. Start trajectory collection

```
ng_collect_traj +agent_name=simple_game_agent +input_jsonl_fpath=data/sudoku_batch.jsonl +output_jsonl_fpath=results/sudoku_output_NEWLOGIC.jsonl
```

---

**Example Rollouts**:

```
{"responses_create_params": {"input": [], "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}]}, "response": {"id": "resp_68bd93aa0e9081948ee1fb98147b354701b662383935ba9f", "created_at": 1757254570.0, "error": null, "incomplete_details": null, "instructions": null, "metadata": {}, "model": "gpt-4.1-2025-04-14", "object": "response", "output": [{"arguments": "{\"row\":2,\"col\":3,\"number\":3}", "call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "name": "make_move", "type": "function_call", "id": "fc_68bd93a1faec8194b1669db531b87b8a039ed859b3babbe5", "status": "completed"}, {"call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "output": "{\"success\": false, \"message\": \"Incorrect move: R2 C3 = 3 violates Sudoku rules\", \"game_state\": {\"current_board\": [[0, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 1, \"correct_moves\": 0}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  .  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":1,\"number\":1}", "call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "name": "make_move", "type": "function_call", "id": "fc_68bd93a31d648193b06f9923513b16640b983aa011463905", "status": "completed"}, {"call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "output": "{\"success\": true, \"message\": \"Correct move! R1 C1 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 2, \"correct_moves\": 1}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":4,\"number\":3}", "call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "name": "make_move", "type": "function_call", "id": "fc_68bd93a44ac081978ee4664c6853523e0e28ca231f6afdf1", "status": "completed"}, {"call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "output": "{\"success\": true, \"message\": \"Correct move! R1 C4 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 3, \"correct_moves\": 2}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":1,\"number\":2}", "call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "name": "make_move", "type": "function_call", "id": "fc_68bd93a5838c8196b7ac194f34837bfb039cf8ecc424db03", "status": "completed"}, {"call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "output": "{\"success\": true, \"message\": \"Correct move! R2 C1 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 4, \"correct_moves\": 3}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":2,\"number\":3}", "call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a6908c8194962f9d783ef9c08405b4c0e16f7cb6be", "status": "completed"}, {"call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C2 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 5, \"correct_moves\": 4}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":3,\"number\":4}", "call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a780408197a8f194c0c7253d3e07d834853ce8c529", "status": "completed"}, {"call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C3 = 4\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 6, \"correct_moves\": 5}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":3,\"col\":4,\"number\":2}", "call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "name": "make_move", "type": "function_call", "id": "fc_68bd93a895148197bfb733d4c5af173f0db6c67fa5f6bb70", "status": "completed"}, {"call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "output": "{\"success\": true, \"message\": \"Correct move! R3 C4 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 7, \"correct_moves\": 6}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":3,\"number\":1}", "call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "name": "make_move", "type": "function_call", "id": "fc_68bd93a992a88193a5a0bf428d294140050e29fd449a66b6", "status": "completed"}, {"call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "output": "{\"success\": true, \"message\": \"Correct move! R4 C3 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 8, \"correct_moves\": 7}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":4,\"number\":4}", "call_id": "call_FAcCh4KDrE657ryKXNgZL695", "name": "make_move", "type": "function_call", "id": "fc_68bd93ab49f481949fa445b5d6ad069501b662383935ba9f", "status": "completed"}, {"call_id": "call_FAcCh4KDrE657ryKXNgZL695", "output": "{\"success\": true, \"message\": \"Correct move! R4 C4 = 4. Congratulations! Puzzle completed!\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 9, \"correct_moves\": 8}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  4\", \"is_complete\": true, \"move_reward\": 1.0}", "type": "function_call_output", "id": null, "status": null}], "parallel_tool_calls": false, "temperature": 1.0, "tool_choice": "auto", "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}], "top_p": 1.0, "background": false, "max_output_tokens": null, "max_tool_calls": 1, "previous_response_id": null, "prompt": null, "reasoning": {"effort": null, "generate_summary": null, "summary": null}, "service_tier": "default", "status": "completed", "text": {"format": {"type": "text"}, "verbosity": "medium"}, "top_logprobs": 0, "truncation": "disabled", "usage": {"input_tokens": 1103, "input_tokens_details": {"cached_tokens": 0}, "output_tokens": 23, "output_tokens_details": {"reasoning_tokens": 0}, "total_tokens": 1126}, "user": null, "prompt_cache_key": null, "safety_identifier": null, "store": true, "input": [{"role": "user", "type": "message", "content": "You are playing a simple version of Sudoku.\nEach row is numbered from 1 to 4, and each column is also numbered from 1 to 4.\nEmpty cells are represented by '.', and pre-filled cells contain digits from 1 to 4.\n\nYour objective is to fill the empty cells in the 4x4 grid with digits from 1 to 4 such that:\n1. Each row contains all digits from 1 to 4 without repetition.\n2. Each column contains all digits from 1 to 4 without repetition.\n3. Each 2x2 subgrid contains all digits from 1 to 4 without repetition.\n\nRules and Instructions:\n1. **Do not overwrite** the initial numbers provided in the grid.\n2. **Only fill** empty cells represented by '.'.\n3. You must respond with the format '\\boxed{row column number}', e.g. \\boxed{1 1 5}.\n4. **Ensure** that your move does not violate Sudoku rules. Invalid moves will result in penalties.\nUse the make_move function to submit your moves. Good luck!\n\n\n\n   C1 C2   C3 C4  \nR1  .  4 |  2  .\nR2  .  . |  .  1\n   - - - - - - \nR3  4  1 |  3  .\nR4  3  2 |  .  ."}]}, "reward": 1.0, "total_moves": 9, "is_complete": true}
```
---

---------

Signed-off-by: Rahul Chand <[email protected]>
Signed-off-by: Abhibha Gupta <[email protected]>
abhibha-nvidia pushed a commit that referenced this pull request Sep 29, 2025
abubakaria56 pushed a commit to abubakaria56/Gym that referenced this pull request Mar 2, 2026
## Details 

This is a resource server for sudoku text based game. The correctness is
checked programtically. The reward is returned at each step (each call
of the `make_move` function. The final reward is the sum)

**Dataset**: The dataset is proceduraly generated. But for it to be
compatible with current trajectory generation framework. We have a
`simple_sudoku.jsonl` and a script (steps below) that can be used to
create a jsonl to use for trajectory generation. This would be changed
later


## Steps to run

1. Download reference dataset

```
ng_download_dataset_to_gitlab \
    +dataset_name=simple_sudoku \
    +version=0.0.2 \
    +artifact_fpath=simple_sudoku.jsonl \
    +output_fpath=data/simple_sudoku.jsonl
```

2. Create a larger jsonl (the reference dataset just has 1 data point as
reference for how the system prompt, tool definition should look like).
Below generates 5 examples. Currently the game parameters , board size &
number of clues are selected randomly in a reasonable range (4 & 9 for
board size and btw (6,12) for board of sizse 4 and (16, 48) for board
size 9. In the future we could replace this with a parameter of how
tough we want the game)

Run below from the `simple_sudoku/` folder
```
python generate_sudoku_jsonl.py ../../data/simple_sudoku.jsonl 5 ../../data/sudoku_batch.jsonl
```


2. Start the servers (this starts the simple_game_agent, the model
server & the sudkoku environment server)

```
ng_run "+config_paths=[responses_api_agents/simple_game_agent/configs/simple_game_agent.yaml,responses_api_models/openai_model/configs/openai_model.yaml,resources_servers/simple_sudoku/configs/simple_sudoku.yaml]" +simple_game_agent.responses_api_agents.simple_game_agent.resources_server.name=simple_sudoku
```

3. Start trajectory collection

```
ng_collect_traj +agent_name=simple_game_agent +input_jsonl_fpath=data/sudoku_batch.jsonl +output_jsonl_fpath=results/sudoku_output_NEWLOGIC.jsonl
```

---

**Example Rollouts**:

```
{"responses_create_params": {"input": [], "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}]}, "response": {"id": "resp_68bd93aa0e9081948ee1fb98147b354701b662383935ba9f", "created_at": 1757254570.0, "error": null, "incomplete_details": null, "instructions": null, "metadata": {}, "model": "gpt-4.1-2025-04-14", "object": "response", "output": [{"arguments": "{\"row\":2,\"col\":3,\"number\":3}", "call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "name": "make_move", "type": "function_call", "id": "fc_68bd93a1faec8194b1669db531b87b8a039ed859b3babbe5", "status": "completed"}, {"call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "output": "{\"success\": false, \"message\": \"Incorrect move: R2 C3 = 3 violates Sudoku rules\", \"game_state\": {\"current_board\": [[0, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 1, \"correct_moves\": 0}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  .  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":1,\"number\":1}", "call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "name": "make_move", "type": "function_call", "id": "fc_68bd93a31d648193b06f9923513b16640b983aa011463905", "status": "completed"}, {"call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "output": "{\"success\": true, \"message\": \"Correct move! R1 C1 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 2, \"correct_moves\": 1}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":4,\"number\":3}", "call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "name": "make_move", "type": "function_call", "id": "fc_68bd93a44ac081978ee4664c6853523e0e28ca231f6afdf1", "status": "completed"}, {"call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "output": "{\"success\": true, \"message\": \"Correct move! R1 C4 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 3, \"correct_moves\": 2}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":1,\"number\":2}", "call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "name": "make_move", "type": "function_call", "id": "fc_68bd93a5838c8196b7ac194f34837bfb039cf8ecc424db03", "status": "completed"}, {"call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "output": "{\"success\": true, \"message\": \"Correct move! R2 C1 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 4, \"correct_moves\": 3}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":2,\"number\":3}", "call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a6908c8194962f9d783ef9c08405b4c0e16f7cb6be", "status": "completed"}, {"call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C2 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 5, \"correct_moves\": 4}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":3,\"number\":4}", "call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a780408197a8f194c0c7253d3e07d834853ce8c529", "status": "completed"}, {"call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C3 = 4\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 6, \"correct_moves\": 5}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":3,\"col\":4,\"number\":2}", "call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "name": "make_move", "type": "function_call", "id": "fc_68bd93a895148197bfb733d4c5af173f0db6c67fa5f6bb70", "status": "completed"}, {"call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "output": "{\"success\": true, \"message\": \"Correct move! R3 C4 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 7, \"correct_moves\": 6}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":3,\"number\":1}", "call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "name": "make_move", "type": "function_call", "id": "fc_68bd93a992a88193a5a0bf428d294140050e29fd449a66b6", "status": "completed"}, {"call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "output": "{\"success\": true, \"message\": \"Correct move! R4 C3 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 8, \"correct_moves\": 7}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":4,\"number\":4}", "call_id": "call_FAcCh4KDrE657ryKXNgZL695", "name": "make_move", "type": "function_call", "id": "fc_68bd93ab49f481949fa445b5d6ad069501b662383935ba9f", "status": "completed"}, {"call_id": "call_FAcCh4KDrE657ryKXNgZL695", "output": "{\"success\": true, \"message\": \"Correct move! R4 C4 = 4. Congratulations! Puzzle completed!\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 9, \"correct_moves\": 8}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  4\", \"is_complete\": true, \"move_reward\": 1.0}", "type": "function_call_output", "id": null, "status": null}], "parallel_tool_calls": false, "temperature": 1.0, "tool_choice": "auto", "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}], "top_p": 1.0, "background": false, "max_output_tokens": null, "max_tool_calls": 1, "previous_response_id": null, "prompt": null, "reasoning": {"effort": null, "generate_summary": null, "summary": null}, "service_tier": "default", "status": "completed", "text": {"format": {"type": "text"}, "verbosity": "medium"}, "top_logprobs": 0, "truncation": "disabled", "usage": {"input_tokens": 1103, "input_tokens_details": {"cached_tokens": 0}, "output_tokens": 23, "output_tokens_details": {"reasoning_tokens": 0}, "total_tokens": 1126}, "user": null, "prompt_cache_key": null, "safety_identifier": null, "store": true, "input": [{"role": "user", "type": "message", "content": "You are playing a simple version of Sudoku.\nEach row is numbered from 1 to 4, and each column is also numbered from 1 to 4.\nEmpty cells are represented by '.', and pre-filled cells contain digits from 1 to 4.\n\nYour objective is to fill the empty cells in the 4x4 grid with digits from 1 to 4 such that:\n1. Each row contains all digits from 1 to 4 without repetition.\n2. Each column contains all digits from 1 to 4 without repetition.\n3. Each 2x2 subgrid contains all digits from 1 to 4 without repetition.\n\nRules and Instructions:\n1. **Do not overwrite** the initial numbers provided in the grid.\n2. **Only fill** empty cells represented by '.'.\n3. You must respond with the format '\\boxed{row column number}', e.g. \\boxed{1 1 5}.\n4. **Ensure** that your move does not violate Sudoku rules. Invalid moves will result in penalties.\nUse the make_move function to submit your moves. Good luck!\n\n\n\n   C1 C2   C3 C4  \nR1  .  4 |  2  .\nR2  .  . |  .  1\n   - - - - - - \nR3  4  1 |  3  .\nR4  3  2 |  .  ."}]}, "reward": 1.0, "total_moves": 9, "is_complete": true}
```
---

---------

Signed-off-by: Rahul Chand <[email protected]>
abubakaria56 pushed a commit to abubakaria56/Gym that referenced this pull request Mar 2, 2026
abubakaria56 pushed a commit to abubakaria56/Gym that referenced this pull request Mar 2, 2026
## Details 

This is a resource server for sudoku text based game. The correctness is
checked programtically. The reward is returned at each step (each call
of the `make_move` function. The final reward is the sum)

**Dataset**: The dataset is proceduraly generated. But for it to be
compatible with current trajectory generation framework. We have a
`simple_sudoku.jsonl` and a script (steps below) that can be used to
create a jsonl to use for trajectory generation. This would be changed
later


## Steps to run

1. Download reference dataset

```
ng_download_dataset_to_gitlab \
    +dataset_name=simple_sudoku \
    +version=0.0.2 \
    +artifact_fpath=simple_sudoku.jsonl \
    +output_fpath=data/simple_sudoku.jsonl
```

2. Create a larger jsonl (the reference dataset just has 1 data point as
reference for how the system prompt, tool definition should look like).
Below generates 5 examples. Currently the game parameters , board size &
number of clues are selected randomly in a reasonable range (4 & 9 for
board size and btw (6,12) for board of sizse 4 and (16, 48) for board
size 9. In the future we could replace this with a parameter of how
tough we want the game)

Run below from the `simple_sudoku/` folder
```
python generate_sudoku_jsonl.py ../../data/simple_sudoku.jsonl 5 ../../data/sudoku_batch.jsonl
```


2. Start the servers (this starts the simple_game_agent, the model
server & the sudkoku environment server)

```
ng_run "+config_paths=[responses_api_agents/simple_game_agent/configs/simple_game_agent.yaml,responses_api_models/openai_model/configs/openai_model.yaml,resources_servers/simple_sudoku/configs/simple_sudoku.yaml]" +simple_game_agent.responses_api_agents.simple_game_agent.resources_server.name=simple_sudoku
```

3. Start trajectory collection

```
ng_collect_traj +agent_name=simple_game_agent +input_jsonl_fpath=data/sudoku_batch.jsonl +output_jsonl_fpath=results/sudoku_output_NEWLOGIC.jsonl
```

---

**Example Rollouts**:

```
{"responses_create_params": {"input": [], "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}]}, "response": {"id": "resp_68bd93aa0e9081948ee1fb98147b354701b662383935ba9f", "created_at": 1757254570.0, "error": null, "incomplete_details": null, "instructions": null, "metadata": {}, "model": "gpt-4.1-2025-04-14", "object": "response", "output": [{"arguments": "{\"row\":2,\"col\":3,\"number\":3}", "call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "name": "make_move", "type": "function_call", "id": "fc_68bd93a1faec8194b1669db531b87b8a039ed859b3babbe5", "status": "completed"}, {"call_id": "call_HRb8CVBJzjVXbqiYvDNf63yS", "output": "{\"success\": false, \"message\": \"Incorrect move: R2 C3 = 3 violates Sudoku rules\", \"game_state\": {\"current_board\": [[0, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 1, \"correct_moves\": 0}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  .  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":1,\"number\":1}", "call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "name": "make_move", "type": "function_call", "id": "fc_68bd93a31d648193b06f9923513b16640b983aa011463905", "status": "completed"}, {"call_id": "call_hM2UMng5iSWnuET4aMpeKIoJ", "output": "{\"success\": true, \"message\": \"Correct move! R1 C1 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 0], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 2, \"correct_moves\": 1}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  .\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":1,\"col\":4,\"number\":3}", "call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "name": "make_move", "type": "function_call", "id": "fc_68bd93a44ac081978ee4664c6853523e0e28ca231f6afdf1", "status": "completed"}, {"call_id": "call_Q866NsiyJeD807NjpnQxJk0V", "output": "{\"success\": true, \"message\": \"Correct move! R1 C4 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [0, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 3, \"correct_moves\": 2}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  .  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":1,\"number\":2}", "call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "name": "make_move", "type": "function_call", "id": "fc_68bd93a5838c8196b7ac194f34837bfb039cf8ecc424db03", "status": "completed"}, {"call_id": "call_giYxUnyIL7BLZCp7hKHPxHn9", "output": "{\"success\": true, \"message\": \"Correct move! R2 C1 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 0, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 4, \"correct_moves\": 3}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  . |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":2,\"number\":3}", "call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a6908c8194962f9d783ef9c08405b4c0e16f7cb6be", "status": "completed"}, {"call_id": "call_y9bTBhRd2FvRDadiap5nNujC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C2 = 3\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 0, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 5, \"correct_moves\": 4}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  .  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":2,\"col\":3,\"number\":4}", "call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "name": "make_move", "type": "function_call", "id": "fc_68bd93a780408197a8f194c0c7253d3e07d834853ce8c529", "status": "completed"}, {"call_id": "call_YV4txJW0g9sgS5UZpS0cnzTC", "output": "{\"success\": true, \"message\": \"Correct move! R2 C3 = 4\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 0], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 6, \"correct_moves\": 5}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  .\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":3,\"col\":4,\"number\":2}", "call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "name": "make_move", "type": "function_call", "id": "fc_68bd93a895148197bfb733d4c5af173f0db6c67fa5f6bb70", "status": "completed"}, {"call_id": "call_tOUxWELZGfigplBp5lEqQLvs", "output": "{\"success\": true, \"message\": \"Correct move! R3 C4 = 2\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 0, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 7, \"correct_moves\": 6}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  .  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":3,\"number\":1}", "call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "name": "make_move", "type": "function_call", "id": "fc_68bd93a992a88193a5a0bf428d294140050e29fd449a66b6", "status": "completed"}, {"call_id": "call_JxdEvztCmWNb0oxvgDzqFJFV", "output": "{\"success\": true, \"message\": \"Correct move! R4 C3 = 1\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 0]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 8, \"correct_moves\": 7}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  .\", \"is_complete\": false, \"move_reward\": 0.0}", "type": "function_call_output", "id": null, "status": null}, {"arguments": "{\"row\":4,\"col\":4,\"number\":4}", "call_id": "call_FAcCh4KDrE657ryKXNgZL695", "name": "make_move", "type": "function_call", "id": "fc_68bd93ab49f481949fa445b5d6ad069501b662383935ba9f", "status": "completed"}, {"call_id": "call_FAcCh4KDrE657ryKXNgZL695", "output": "{\"success\": true, \"message\": \"Correct move! R4 C4 = 4. Congratulations! Puzzle completed!\", \"game_state\": {\"current_board\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"solution\": [[1, 4, 2, 3], [2, 3, 4, 1], [4, 1, 3, 2], [3, 2, 1, 4]], \"scale\": 4, \"initial_empty_count\": 8, \"moves_made\": 9, \"correct_moves\": 8}, \"board_text\": \"   C1 C2   C3 C4  \\nR1  1  4 |  2  3\\nR2  2  3 |  4  1\\n   - - - - - - \\nR3  4  1 |  3  2\\nR4  3  2 |  1  4\", \"is_complete\": true, \"move_reward\": 1.0}", "type": "function_call_output", "id": null, "status": null}], "parallel_tool_calls": false, "temperature": 1.0, "tool_choice": "auto", "tools": [{"name": "make_move", "parameters": {"type": "object", "properties": {"row": {"type": "integer", "description": "Row number (1-4)"}, "col": {"type": "integer", "description": "Column number (1-4)"}, "number": {"type": "integer", "description": "Digit to place (1-4)"}}, "required": ["row", "col", "number"], "additionalProperties": false}, "strict": true, "type": "function", "description": "Place a digit in the Sudoku grid"}], "top_p": 1.0, "background": false, "max_output_tokens": null, "max_tool_calls": 1, "previous_response_id": null, "prompt": null, "reasoning": {"effort": null, "generate_summary": null, "summary": null}, "service_tier": "default", "status": "completed", "text": {"format": {"type": "text"}, "verbosity": "medium"}, "top_logprobs": 0, "truncation": "disabled", "usage": {"input_tokens": 1103, "input_tokens_details": {"cached_tokens": 0}, "output_tokens": 23, "output_tokens_details": {"reasoning_tokens": 0}, "total_tokens": 1126}, "user": null, "prompt_cache_key": null, "safety_identifier": null, "store": true, "input": [{"role": "user", "type": "message", "content": "You are playing a simple version of Sudoku.\nEach row is numbered from 1 to 4, and each column is also numbered from 1 to 4.\nEmpty cells are represented by '.', and pre-filled cells contain digits from 1 to 4.\n\nYour objective is to fill the empty cells in the 4x4 grid with digits from 1 to 4 such that:\n1. Each row contains all digits from 1 to 4 without repetition.\n2. Each column contains all digits from 1 to 4 without repetition.\n3. Each 2x2 subgrid contains all digits from 1 to 4 without repetition.\n\nRules and Instructions:\n1. **Do not overwrite** the initial numbers provided in the grid.\n2. **Only fill** empty cells represented by '.'.\n3. You must respond with the format '\\boxed{row column number}', e.g. \\boxed{1 1 5}.\n4. **Ensure** that your move does not violate Sudoku rules. Invalid moves will result in penalties.\nUse the make_move function to submit your moves. Good luck!\n\n\n\n   C1 C2   C3 C4  \nR1  .  4 |  2  .\nR2  .  . |  .  1\n   - - - - - - \nR3  4  1 |  3  .\nR4  3  2 |  .  ."}]}, "reward": 1.0, "total_moves": 9, "is_complete": true}
```
---

---------

Signed-off-by: Rahul Chand <[email protected]>
abubakaria56 pushed a commit to abubakaria56/Gym that referenced this pull request Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants