Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Show why the look check could not draw a recipe

Nguyen Xuan An7a81412ce06d
diff --git a/bench/agent-modeling/check.mjs b/bench/agent-modeling/check.mjs
index 843e4bec..c59736a7 100644
--- a/bench/agent-modeling/check.mjs
+++ b/bench/agent-modeling/check.mjs
@@ -294,7 +294,7 @@ function checkOne(check, measures) {
return checkWalkPath(check, measures);
case 'renderedLook': {
const look = measures.renderedLook;
- if (!look) return { pass: false, detail: 'the recipe could not be drawn' };
+ if (!look || look.drawError) return { pass: false, detail: `the recipe could not be drawn${look?.drawError ? `: ${look.drawError}` : ''}` };
const [lowest, highest] = check.brightness;
const problems = [];
if (look.meanBrightness < lowest) problems.push('too dim');
@@ -441,7 +441,8 @@ export async function gradeRecipe(task, recipe) {
}
if (task.checks.some(check => check.kind === 'renderedLook')) {
const { measureRenderedLook } = await import('./look.mjs');
- measures.renderedLook = await measureRenderedLook(recipe).catch(() => null);
+ // Keep the reason: a browser or page error must show in the check's detail, not read as a dim picture.
+ measures.renderedLook = await measureRenderedLook(recipe).catch(error => ({ drawError: error.message }));
}
const results = task.checks.map(check => ({ kind: check.kind, ...(check.label ? { label: check.label } : {}), ...checkOne(check, measures) }));
const passed = results.filter(result => result.pass).length;
diff --git a/tests/agent-modeling-suite.test.js b/tests/agent-modeling-suite.test.js
index b86db0a1..7b34af6d 100644
--- a/tests/agent-modeling-suite.test.js
+++ b/tests/agent-modeling-suite.test.js
@@ -10,7 +10,8 @@ import { EASING_PLAIN_SOLUTION } from '../bench/agent-modeling/easing.mjs';
test('the look pick passes the golden grade and fails the dim, the pale and a moved scene', async () => {
const task = taskById('look-pick');
- assert.deepEqual(failedKinds(await gradeRecipe(task, structuredClone(REFERENCES['look-pick']))), []);
+ const golden = await gradeRecipe(task, structuredClone(REFERENCES['look-pick']));
+ assert.deepEqual(failedKinds(golden), [], failedDetails(golden));
for (const [name, reason] of [['dusk', /too dim/], ['airy', /too pale/]]) {
const wrongGrade = structuredClone(REFERENCES['look-pick']);
@@ -30,6 +31,7 @@ test('the look pick passes the golden grade and fails the dim, the pale and a mo
});
const failedKinds = grade => grade.results.filter(result => !result.pass).map(result => result.label ?? result.kind);
+const failedDetails = grade => JSON.stringify(grade.results.filter(result => !result.pass));
test('every task has a reference solution that passes all its checks', async () => {
assert.deepEqual(Object.keys(REFERENCES).sort(), TASKS.map(task => task.id).sort());