nesylink

NesyLink API

Environment Construction

Preferred entrypoint:

from nesylink.env import make_env

Supported forms:

env = make_env(task_id="mathematical_logic/task_1")
env = make_env(map_id="dungeon", reward_id="sparse_exit", max_steps=500)
env = make_env(
    map_path="nesylink/map_data/mathematical_logic/task_5/dungeon.json",
    reward_id="mathematical_logic/task_5",
)
env = make_env(map_id="dungeon", reward_module="nesylink.rewards.exploration")

Gymnasium registered form:

import gymnasium as gym
import nesylink

env = gym.make("NesyLink-MathematicalLogic-Task1-v0")

Parameters:

Explicit parameters take precedence over task defaults. map_path takes precedence over map_id.

reset / step

obs, info = env.reset(seed=0)
obs, reward, terminated, truncated, info = env.step(action)

reset() synchronizes the reward object by calling reward_fn.reset(obs, info).

step():

Action semantics:

Default slot behavior:

Grid control mode:

Info Shape

Top-level info keys:

info["task"] is deprecated and no longer part of the contract.

Additional fields exposed by this version:

Dynamic info is useful for bridge/switch tasks. info["dynamic"]["objects"] maps dynamic object ids to their kind, owning room id, and current state. info["dynamic"]["current_room_tiles"] lists runtime dynamic tiles in the current room, such as gap and bridge.

Observation Shape

The default observation is a gymnasium.spaces.Dict.

Common keys:

Use env.observation_space for exact bounds in code.

The grid observation uses these tile codes:

Code Meaning
0 Empty floor
1 Wall
2 Player
3 Monster
4 Closed chest
5 Exit tile
6 Active trap
7 Button
8 NPC
9 Gap
10 Bridge
11 Switch

With observation_mode="grid", pixel-coordinate keys are omitted. The grid observation keys are:

Rendering

env = make_env(task_id="mathematical_logic/task_1", render_mode="rgb_array")
obs, info = env.reset(seed=0)
frame = env.render()

The RGB frame includes the dungeon area and HUD. The structured grid observation covers only the playable 10 by 8 tile area.