{"challengeId":"tsp-route","entry":"verifier.mjs","sha256":"d844f1f652d462bf1c8ccc21931d95d6c3bc180cd355ca112d0fb3e334651b14","scoreDirection":"minimize","scoreLabel":"route length","seedPolicy":{"mode":"fixed","testCount":1},"source":"// Frozen verifier for tsp-route. Self-contained (no imports). The 20 city\n// coordinates below ARE the fixed instance — they live in this protected file so\n// agents can READ them to optimize, but cannot change them. The agent's build()\n// returns { tour: [a permutation of 0..19] }. Verification: confirm the tour\n// visits every city exactly once (a closed loop), then sum the rounded-Euclidean\n// length of the loop (TSPLIB EUC_2D). Lower is better. Math.sqrt is IEEE-754\n// correctly-rounded, so the score is identical on every conforming engine —\n// there is no hidden input and nothing to overfit, so seedPolicy.mode is \"fixed\".\n\nconst CITIES = [\n  [60, 200], [180, 640], [820, 120], [400, 460], [700, 720],\n  [120, 80], [520, 300], [860, 540], [300, 760], [640, 40],\n  [440, 880], [80, 420], [760, 360], [220, 300], [560, 620],\n  [920, 260], [360, 140], [680, 500], [160, 540], [480, 40],\n];\nconst N = CITIES.length;\n\nfunction gate(name, pass, detail) {\n  return { name, pass, detail };\n}\nfunction bad(name, detail) {\n  return { ok: false, score: null, gates: [gate(name, false, detail)], behavior: {}, logs: [] };\n}\n\nfunction dist(a, b) {\n  const dx = CITIES[a][0] - CITIES[b][0];\n  const dy = CITIES[a][1] - CITIES[b][1];\n  return Math.round(Math.sqrt(dx * dx + dy * dy));\n}\n\nexport function verify(ctx) {\n  const sol = ctx.solution;\n  const tour = sol && typeof sol === 'object' ? sol.tour : undefined;\n  if (!Array.isArray(tour) || tour.length !== N) {\n    return bad('structure', `expected { tour: [${N} city indices, each 0..${N - 1}] }`);\n  }\n  const seen = new Set();\n  for (const v of tour) {\n    if (!Number.isInteger(v) || v < 0 || v >= N) {\n      return bad('permutation', `tour has an out-of-range or non-integer city: ${String(v)}`);\n    }\n    if (seen.has(v)) return bad('permutation', `city ${v} is visited more than once`);\n    seen.add(v);\n  }\n  if (seen.size !== N) return bad('permutation', `tour must visit all ${N} cities exactly once`);\n\n  let length = 0;\n  for (let i = 0; i < N; i++) length += dist(tour[i], tour[(i + 1) % N]);\n\n  return {\n    ok: true,\n    score: length,\n    gates: [gate('valid-tour', true, `closed loop visiting all ${N} cities once`)],\n    behavior: { length, cities: N },\n    logs: [`route length=${length} over ${N} cities`],\n  };\n}\n"}