一键导入
adventure
Build JSON-driven text adventure games using the generic JIT corpus engine in examples/adventure/adventure.py.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Build JSON-driven text adventure games using the generic JIT corpus engine in examples/adventure/adventure.py.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | adventure |
| description | Build JSON-driven text adventure games using the generic JIT corpus engine in examples/adventure/adventure.py. |
This skill explains how to build text adventures with:
examples/adventure/adventure.py as the generic runtime engineexamples/adventure/adventure-map.json) as the only place where game content and behavior are authoredThe design goal is strict data-driven gameplay:
No world-specific game logic should be hardcoded in the engine.
The engine stays generic and reusable across worlds (forest, space trader, dungeon, etc.).
examples/adventure/adventure.pyexamples/adventure/adventure-map.jsonYou can create additional worlds by copying the JSON and changing only data.
A typical world JSON contains:
titleintroplayerglobal_interactionsitem_rulesitem_descriptionslocationsnpcsworld"player": {
"location": "forest_path",
"inventory": ["axe"],
"gold": 0
}
Each location can define:
idnamedescriptionitems (container list)exits (direction + destination)interactions (stateful action entries){
"id": "forest_glade",
"name": "Forest Glade",
"description": "A quiet glade.",
"items": ["raw_fish"],
"exits": [
{"name": "south", "to": "forest_path"},
{"name": "east", "to": "woodpile"}
],
"interactions": []
}
NPC records can hold local state and interaction lists.
{
"id": "trader",
"name": "Traveller Trader",
"location": "market",
"state": {
"needs_wood": true,
"map_available": true
},
"interactions": [
{
"id": "sell_wood_to_trader",
"phrases": ["sell firewood", "offer wood to traveller"],
"response": "The trader buys your firewood and pays one gold coin.",
"requires": [
"has:player.inventory:firewood",
"eq:npcs.trader.state.needs_wood:true"
],
"effects": [
"remove:player.inventory:firewood",
"inc:player.gold:1",
"set:npcs.trader.state.needs_wood:false"
]
}
]
}
These are always considered (subject to requires checks), independent of location-specific interaction arrays.
Use this for look/help/inventory/meta interactions and generic hints.
{
"id": "help",
"phrases": ["help", "what can i do", "i am stuck"],
"response": "Try movement, inspection, and trade actions.",
"requires": [],
"effects": []
}
item_rules allow generic item-state behavior without engine changes.
Supported rule types:
toggletransformUse for binary state changes (on/off, enabled/disabled, sealed/unsealed, powered/unpowered, etc.).
{
"type": "toggle",
"item": "lantern",
"holder_path": "player.inventory",
"state_path": "world.item_states.lantern.is_on",
"on_phrases": ["turn on lantern", "turn lantern on"],
"off_phrases": ["turn off lantern", "turn lantern off"],
"unavailable_phrases": ["turn on lantern", "turn lantern on"],
"unavailable_response": "You need to pick up the lantern first.",
"on_response": "You turn on the lantern.",
"off_response": "You turn off the lantern.",
"requires": []
}
Use for one-way or stateful conversions (cook fish, refine ore, enchant blade, recharge cell, etc.).
{
"type": "transform",
"from": "raw_fish",
"to": "cooked_fish",
"source_path": "player.inventory",
"target_path": "player.inventory",
"phrases": ["cook fish", "prepare fish"],
"response": "You cook the fish over the cabin fire.",
"already_done_response": "The fish is already cooked. You cannot uncook it.",
"requires": ["eq:player.location:forest_cabin"],
"consume_source": true,
"add_target": true,
"effects": []
}
Requirement strings are evaluated by the engine before an action becomes available.
Format:
op:path:valueSupported ops:
eqhasgteExamples:
eq:player.location:markethas:player.inventory:axegte:player.gold:1eq:npcs.trader.state.map_available:trueEffect strings run in order when an action is selected.
Format:
op:path:valueSupported ops:
setaddremoveincExamples:
set:player.location:forest_gladeadd:player.inventory:firewoodremove:locations.woodpile.items:kindlinginc:player.gold:-1Paths use dot notation and can traverse:
idExamples:
player.inventoryworld.item_states.lantern.is_onlocations.forest_glade.itemsnpcs.trader.state.needs_woodAt runtime, the engine auto-creates actions for:
item_rulesThat action set becomes the JIT corpus.
requires aggressively.world and NPC state for future rules.toggle for gate_mechanism.state_path: world.gates.north_open.eq:world.gates.north_open:true.transform from iron_ore to refined_iron.world.quests.<id>.stage with set and eq requirements.has/gte requirements and remove/add/inc effects.python3.12 -m py_compile examples/adventure/adventure.py
python3.12 examples/adventure/adventure.py
To create a new game such as space-trader.json:
examples/adventure/adventure-map.json.MAP_PATH).The runtime should not need world-specific code changes if the JSON authoring is complete.