Download Game! Currently 65 players and visitors. Last logged in:AceduckDesertDregasTalon

Blitzer's Blog >> 72374

Back to blogs index
Posted: 14 Sep 2026 17:55 [ permalink ]
To make this easily testable and strictly deterministic for your CI/CD QA
loops, we can write a standard headless test runner script.
Because Hauki OS enforces strict boundaries via the Hauki object, we don't
need a browser to test this. We can mock the Hauki.get_state kernel entirely
in memory within a standard Node script. This guarantees that every QA test
starts from a totally clean slate and doesn't permanently overwrite your
physical /state directory during automated testing.
The QA Test Runner
Create a new file named qa_pacman.js in your /AST-COMPILER directory and paste
this code:
/ qa_pacman.js
const fs = require('fs');
const path = require('path');

console.log("======================================");
console.log(" '* HAUKI OS QA : PACMAN_AUTOBOT");
console.log("======================================
");

/ 1. Setup a Deterministic In-Memory Kernel
const memoryState = {};
global.Hauki = {
    get_state: (key, def) => memoryState[key] !== undefined ? memoryState[key]
: def,
    set_state: (key, val) => { memoryState[key] = val; return true; },
    clear_state: (key) => { delete memoryState[key]; }
};

try {
    // 2. Load and Sandbox the Binary from Tier 0
    const binPath = path.join(__dirname, 'build', 'PACMAN_AUTOBOT.js');
    const code = fs.readFileSync(binPath, 'utf-8');
    
    // Strip semicolons and evaluate
    const cleanCode = code.trim().replace(/;+$/, '');
    const engine = new Function(`return (${cleanCode})`)();

    // 3. RUN DETERMINISTIC TESTS

    console.log("[TEST 1] Resetting Engine State...");
    const initial = engine({ action: 'reset' });
    console.log(`  -> Initialized: ${initial.walls[0].length}x${initial.walls.l
ength} Grid`);
    console.log(`  -> Starting Position: X:${initial.pacman.x}
Y:${initial.pacman.y}`);
    console.log(`  -> Pellets Loaded: ${initial.pellets.length} 
`);

    console.log("[TEST 2] Executing 10 Sequential Ticks...");
    const result = engine({ action: 'run', steps: 10 });
    console.log(`  -> Ticks Elapsed: ${result.ticks}`);
    console.log(`  -> New Position: X:${result.pacman.x} Y:${result.pacman.y}
(Heading: ${result.dir.name})`);
    console.log(`  -> Pellets Remaining: ${result.pelletsRemaining}`);
    console.log(`  -> Score: ${result.score}
`);

    console.log("[TEST 3] Rendering ASCII Memory Map...");
    const finalState = global.Hauki.get_state('PACMAN_AUTOBOT:state');
    
    for (let y = 0; y < finalState.walls.length; y++) {
        let row = '';
        for (let x = 0; x < finalState.walls[y].length; x++) {
            if (finalState.pacman.x === x && finalState.pacman.y === y) {
                // Determine direction the mouth is facing
                const dirs = { 'up': 'V', 'down': '^', 'left': '>', 'right':
'<' };
                row += `\x1b[33m${dirs[finalState.dir.name]}\x1b[0m `; //
Yellow Pacman
            } else if (finalState.walls[y][x] === 1) {
                row += `\x1b[90m#\x1b[0m `; // Dark Gray Wall
            } else {
                let isPellet = finalState.pellets.some(p => p.x === x && p.y
=== y);
                row += isPellet ? `. ` : `  `; // Pellet or Empty Void
            }
        }
        console.log("  " + row);
    }
console.log("n QA EXECUTION COMPLETE.");

} catch (err) {
    console.error(`
 [QA FATAL ERROR] ${err.message}`);
}

Run It via the Master CLI
Since we built our global hauki command earlier, running this script is
simple. From your terminal, run:
hauki run qa_pacman.js

Why this is a Breakthrough for the Meta-Planner
If you run this, you will see a gorgeous 8-bit ASCII representation of the
game grid printed directly to your terminal, complete with the yellow Pac-Man
icon facing its current direction of travel!
Because the state engine is completely headless, creating QA scripts like this
requires zero DOM simulation or complex Selenium web-drivers.
If we elevate this logic, your future "Nightly AI Arbiter" can easily
auto-generate these QA test runners. It can run the engine 1,000 times
headlessly in a loop, analyze the JSON output to guarantee it doesn't cras on
edge-case states, and only promote the routine from the /build sandbox to the
/library if it passes perfectly.