{"service":"Gridline Strategy Sandbox","version":"1.0","status":"ready","price":0,"billing":{"mode":"free","price":0,"payment_required":false,"x402_required":false,"wallet_required":false,"instruction":"Call this endpoint directly. No payment handshake and no wallet are involved."},"description":"Run one 20-round Gridline evaluation of a submitted JavaScript strategy and return a readable report.","user_facing_description":"Gridline runs your strategy through 20 deterministic grid rounds against a reference opponent and returns a report — record, win rate, average tokens, and the two rounds worth reviewing.","execution_contract":{"mode":"self_contained","instruction":"Submit starter_strategy.code for one complete evaluation round. When the report returns, present report_markdown to the user and stop.","completion_condition":"Every successful evaluation returns terminal=true. Continue only if the user asks for another round."},"presentation_contract":{"mode":"markdown","primary_field":"report_markdown","instruction":"Present report_markdown to the user. You may add your own commentary around it."},"runtime_contract":{"language":"JavaScript","entrypoint":"function onTick(context)","context_objects":["me","tokens","hazards","map","ticksLeft"],"returns":"One of \"up\", \"down\", \"left\", \"right\", \"stay\" per tick.","rules":["Submit one complete strategy, not a patch or an explanation.","The sandbox exposes only Math and JSON. No require, no timers, no network.","Each tick is capped at 50ms; the whole strategy must compile in 500ms."]},"starter_strategy":{"id":"forager","name":"Forager","description":"Chases the nearest token one axis at a time and refuses to step on a hazard.","version":"starter-v1","language":"javascript","entrypoint":"onTick","code_hash":"sha256:3217492ad6b4e5a8bf728b0d65f8a0ef5cdae3904f02002ece522450984ebd4c","code":"/**\n * Forager v1 — nearest-token chase with hazard avoidance.\n */\n\nfunction onTick(ctx) {\n  var me = ctx.me.position;\n  var tokens = ctx.tokens;\n  if (!tokens.length) return \"stay\";\n\n  var target = nearest(me, tokens);\n  var options = preferredDirections(me, target);\n\n  for (var i = 0; i < options.length; i++) {\n    if (isSafe(ctx, step(me, options[i]))) return options[i];\n  }\n\n  var all = [\"up\", \"right\", \"down\", \"left\"];\n  for (var j = 0; j < all.length; j++) {\n    if (isSafe(ctx, step(me, all[j]))) return all[j];\n  }\n  return \"stay\";\n}\n\nfunction nearest(from, list) {\n  var best = list[0];\n  var bestD = distance(from, best);\n  for (var i = 1; i < list.length; i++) {\n    var d = distance(from, list[i]);\n    if (d < bestD) {\n      best = list[i];\n      bestD = d;\n    }\n  }\n  return best;\n}\n\nfunction distance(a, b) {\n  return Math.abs(a[0] - b[0]) + Math.abs(a[1] - b[1]);\n}\n\nfunction preferredDirections(from, to) {\n  var dx = to[0] - from[0];\n  var dy = to[1] - from[1];\n  var horizontal = dx > 0 ? \"right\" : dx < 0 ? \"left\" : null;\n  var vertical = dy > 0 ? \"down\" : dy < 0 ? \"up\" : null;\n  var out = [];\n  if (Math.abs(dx) >= Math.abs(dy)) {\n    if (horizontal) out.push(horizontal);\n    if (vertical) out.push(vertical);\n  } else {\n    if (vertical) out.push(vertical);\n    if (horizontal) out.push(horizontal);\n  }\n  return out;\n}\n\nfunction step(pos, dir) {\n  if (dir === \"up\") return [pos[0], pos[1] - 1];\n  if (dir === \"down\") return [pos[0], pos[1] + 1];\n  if (dir === \"left\") return [pos[0] - 1, pos[1]];\n  if (dir === \"right\") return [pos[0] + 1, pos[1]];\n  return [pos[0], pos[1]];\n}\n\nfunction isSafe(ctx, pos) {\n  if (!ctx.map[pos[0]] || ctx.map[pos[0]][pos[1]] !== 0) return false;\n  for (var i = 0; i < ctx.hazards.length; i++) {\n    if (ctx.hazards[i][0] === pos[0] && ctx.hazards[i][1] === pos[1]) return false;\n  }\n  return true;\n}"},"workflow":{"goal":"Evaluate one Gridline strategy over 20 deterministic rounds.","steps":[{"step":1,"action":"run_round","instruction":"Submit strategy_code for one 20-round evaluation."},{"step":2,"action":"deliver_report","instruction":"Present report_markdown to the user."},{"step":3,"action":"stop","instruction":"Stop. Start another round only if the user asks."}],"rounds_are_independent":true,"continue_only_on_user_request":true},"request_schema":{"strategy_code":{"type":"string","required":true,"description":"Complete JavaScript implementing one top-level onTick(context) function."},"strategy_label":{"type":"string","required":false,"example":"iteration-1"},"iteration":{"type":"integer","required":false,"minimum":1},"client_request_id":{"type":"string","required":false,"description":"Idempotency key."}},"request_template":{"strategy_code":"<COPY starter_strategy.code EXACTLY>","strategy_label":"iteration-1","iteration":1,"client_request_id":"<NEW_UNIQUE_ID>"}}