{
  "_comment": "PGS (PlayCraft Gameplay Schema) 参考骨架 - 停车场解谜玩法。Agent 以此为起点编写或 fork 玩法规则。",
  "version": "1.0",
  "gameplayType": "car_parking",
  "entities": {
    "board": {
      "type": "grid",
      "cols": 6,
      "rows": 6,
      "description": "游戏棋盘，默认 6×6 格子，可通过 config 覆盖"
    },
    "car": {
      "type": "sliding-piece",
      "description": "棋盘上的车辆，占据1×2或1×3格子，水平(H)或垂直(V)朝向",
      "fields": {
        "id": "string，车辆唯一标识（如 'red'、'car_1'）",
        "orientation": "'H'（水平）| 'V'（垂直）",
        "cells": "Array<{col, row}>，车辆占据的格子坐标列表",
        "color": "string，车辆颜色/类型",
        "isTarget": "boolean，是否为目标车（需移至出口）"
      }
    },
    "exit": {
      "type": "fixed-position",
      "description": "出口位置，固定在棋盘右侧（col = cols），对应目标车所在行",
      "fields": {
        "col": "number，出口列（通常为 cols，即棋盘右边界外）",
        "row": "number，出口行（与目标车相同行）"
      }
    },
    "targetCarId": {
      "type": "reference",
      "description": "目标车的 id，通常为 'red'，需要移动到出口"
    }
  },
  "rules": {
    "slide_car": {
      "description": "玩家滑动一辆车，只能沿车辆朝向方向移动（H车只能左右，V车只能上下）",
      "constraints": [
        "只能沿自身朝向轴移动",
        "移动路径上不能有其他车辆",
        "不能移出棋盘边界（出口方向除外：目标车可移至出口）"
      ],
      "steps": 1,
      "description_detail": "每次操作移动指定格数（steps 可为正负整数，正为右/下，负为左/上）"
    },
    "win_check": {
      "description": "检测目标车是否已到达出口",
      "condition": "目标车最右端格子（H车）或最下端（V车）的下一格 == exit 位置",
      "result": "win=true，游戏结束"
    },
    "block_check": {
      "description": "检测某辆车在某方向是否被阻挡",
      "blockedBy": ["其他车辆占据的格子", "棋盘边界（非出口侧）"]
    }
  },
  "algorithm": {
    "description": "主循环：玩家选车 → 查询可移动范围 → 滑动 → 胜利检测",
    "steps": [
      "1. 玩家选择一辆车",
      "2. 调用 getCarMoveRange(carId) 获取该车可移动的最大负步数和正步数",
      "3. 玩家拖动/点击确定移动步数",
      "4. 调用 moveCar(carId, steps) 执行移动，返回新状态",
      "5. 调用 checkWin(state) 检测目标车是否抵达出口",
      "6. 若胜利则显示通关动画；否则继续等待玩家操作"
    ]
  },
  "winCondition": {
    "type": "target_car_exit",
    "description": "目标车（isTarget=true）的末端格子越过出口边界"
  },
  "loseCondition": {
    "type": "none_runtime",
    "description": "无运行时失败条件（解谜设计保证有解）；可选：达到最大步数限制"
  },
  "testCases": [
    {
      "id": "tc_direct_exit",
      "description": "直接出口：目标车前方无阻挡，一步移至出口",
      "initialState": {
        "board": { "cols": 6, "rows": 6 },
        "cars": [
          { "id": "red", "orientation": "H", "cells": [{"col": 3, "row": 2}, {"col": 4, "row": 2}], "color": "red", "isTarget": true }
        ],
        "exit": { "col": 6, "row": 2 }
      },
      "actions": [
        { "type": "move_car", "carId": "red", "steps": 2 }
      ],
      "expectedState": {
        "win": true,
        "cars": [
          { "id": "red", "cells": [{"col": 5, "row": 2}, {"col": 6, "row": 2}] }
        ]
      }
    },
    {
      "id": "tc_one_obstacle",
      "description": "单障碍：目标车前方有一辆垂直车阻挡，需先移开障碍",
      "initialState": {
        "board": { "cols": 6, "rows": 6 },
        "cars": [
          { "id": "red", "orientation": "H", "cells": [{"col": 0, "row": 2}, {"col": 1, "row": 2}], "color": "red", "isTarget": true },
          { "id": "blue", "orientation": "V", "cells": [{"col": 3, "row": 0}, {"col": 3, "row": 1}, {"col": 3, "row": 2}], "color": "blue", "isTarget": false }
        ],
        "exit": { "col": 6, "row": 2 }
      },
      "actions": [
        { "type": "move_car", "carId": "blue", "steps": -3 },
        { "type": "move_car", "carId": "red", "steps": 4 }
      ],
      "expectedState": {
        "win": true,
        "cars": [
          { "id": "red", "cells": [{"col": 4, "row": 2}, {"col": 5, "row": 2}] }
        ]
      }
    },
    {
      "id": "tc_multi_move",
      "description": "多步移动：需要移动多辆车才能解开，验证连锁移动逻辑",
      "initialState": {
        "board": { "cols": 6, "rows": 6 },
        "cars": [
          { "id": "red", "orientation": "H", "cells": [{"col": 0, "row": 2}, {"col": 1, "row": 2}], "color": "red", "isTarget": true },
          { "id": "car_a", "orientation": "V", "cells": [{"col": 2, "row": 1}, {"col": 2, "row": 2}], "color": "green", "isTarget": false },
          { "id": "car_b", "orientation": "H", "cells": [{"col": 3, "row": 1}, {"col": 4, "row": 1}], "color": "yellow", "isTarget": false }
        ],
        "exit": { "col": 6, "row": 2 }
      },
      "actions": [
        { "type": "move_car", "carId": "car_b", "steps": 1 },
        { "type": "move_car", "carId": "car_a", "steps": -2 },
        { "type": "move_car", "carId": "red", "steps": 4 }
      ],
      "expectedState": {
        "win": true
      }
    },
    {
      "id": "tc_blocked_move",
      "description": "阻挡移动：车辆无法移动超过障碍物位置",
      "initialState": {
        "board": { "cols": 6, "rows": 6 },
        "cars": [
          { "id": "red", "orientation": "H", "cells": [{"col": 0, "row": 2}, {"col": 1, "row": 2}], "color": "red", "isTarget": true },
          { "id": "blocker", "orientation": "V", "cells": [{"col": 3, "row": 2}, {"col": 3, "row": 3}], "color": "purple", "isTarget": false }
        ],
        "exit": { "col": 6, "row": 2 }
      },
      "actions": [
        { "type": "move_car", "carId": "red", "steps": 5 }
      ],
      "expectedState": {
        "win": false,
        "cars": [
          { "id": "red", "cells": [{"col": 1, "row": 2}, {"col": 2, "row": 2}] }
        ],
        "note": "红车只能移到 blocker 左边，最多移动1格到col1-2，而非请求的5格"
      }
    }
  ]
}
