Skip to content
OpenEnvisionGameMap
GameMap
GameMap
LearnGuides & notes
Game enginesPrototype a game rule in Three.jsGraybox and playtestState, resets & replaysRead and compare benchmarksStudy browser game cases

Templates & project notes

中文/English

Test a game rule in a Three.js prototype

  • 4 sections

A character carries three fuses to the exit and the game declares a win. That run is consistent with several rules: perhaps any three fuses suffice, perhaps every fuse in the room is required, or perhaps reaching the exit is enough. You will add a fourth fuse to a small Three.js game and replay the same route. The two builds should give different outcomes at the same square.

Establish a baseline

Open the playable room and start a round. The board has seven columns and five rows. Read positions as column and row, starting from zero at the upper left. Your character begins at (0, 4), the exit is at (6, 4), and the fuses lie at (0, 0), (3, 0) and (6, 0). A patrol moves horizontally across the middle row. Use the arrow keys, WASD or the on-screen controls. Tap once per move.

Take four steps up, six right and four down. This route visits the three fuses along the top and approaches the exit from above. The patrol stays clear of both edges. You should win on move 14 if you finish within 45 seconds of active play. Restart and take six steps right along the bottom edge. This time the same exit should leave the round in progress with zero fuses. Together the two runs rule out a simple “reach the exit” condition.

Trace a move from input to screen

Download the editable room, extract it, and open a terminal in the directory containing index.html and rules.js. With Python 3 installed, start a local server and open http://127.0.0.1:8000/ in your browser. The archive includes Three.js r180 and its license. You can run the exercise locally without a package install.

python3 -m http.server 8000 --bind 127.0.0.1

Start in the rules module. Follow one legal move from the old square to the new square. The patrol advances one step, and entering a fuse square credits that fuse once. Now find the test for entering the exit. Notice which quantities the code compares. Looking at the visible exit alone cannot tell you whether the winning restriction is enforced.

In the scene code, makeScene builds the meshes once. The orthographic camera looks down on the XZ plane. Changing a board column moves the player along X, changing a row moves it along Z, and the player's height stays fixed. Look for these three lines inside draw. They place the character, show the gate bar while fuses are missing, and draw the board through the camera.

player.position.set(state.player.x, 0.35, state.player.z);
barrier.visible = state.collected.size !== FUSES.length;
renderer.render(scene, camera);

The gate bar and the win condition both read the collection count. They can still disagree if a later edit changes just one of them. At the end of a run, check the visible bar as well as the reported outcome. The Three.js scene tutorial explains how the camera and renderer produce the image.

Add one fuse and replay the route

In your local copy of rules.js, find FUSES. Append one position so the array contains the following four entries. Keep the timer, patrol and other positions fixed. Save and reload the page.

export const FUSES = [
  { x: 0, z: 0 },
  { x: 3, z: 0 },
  { x: 6, z: 0 },
  { x: 5, z: 4 },
];

The new fuse should appear one square left of the exit. Repeat the original fourteen moves. On reaching the exit you should see three of four fuses collected and a round still in progress. Move left once to take the fourth fuse, then right once to return to the exit. The modified build should win on move 16. If it wins on move 14, inspect the exit condition for a fixed count of three. If it stays locked on move 16, compare the collection record with the four configured positions.

Check what the edit might have broken

Start a fresh round for each row. Keep the browser tab in the foreground for the timeout test.

ProcedureExpected observation
Go four steps up to the first fuse, move one square away and step back.The fuse disappears once. Returning to its square leaves the count at one.
From the starting square, go two steps up and four right.On move six the character and patrol exchange squares. The round ends in a collision. Checking only whether the final squares coincide would miss this contact.
Start a round and stay at the starting square for 45 seconds of active play.The round ends on time with no fuses collected. This tests a different failure condition from patrol contact.
Restart after a win, a collision and a timeout.The character returns to (0, 4), the patrol to (1, 2), and all configured fuses are present again. The counter and time allowance return to their initial values.

For a study of a development agent, give it the original room and a request to place the extra fuse. Keep the two route specifications as independent checks. Record the build, ordered moves, fuse count when the exit was first reached, and final outcome. These observations support a claim about how the submitted game handles this rule. To study whether players understand the rule, observe their first visit to the locked exit before telling them what to collect. The graybox playtest guide describes how to record a player's first choice. For scoring agent submissions, continue with development agent evaluation.

Sources & document information

Prototype mechanics, observe players, and reproduce published comparisons.

View Markdown source

Game engines

Previous Page

Graybox and playtest

Next Page

GameMap

A little direction for your next playable world.

Games

  • Game examples

Tools

  • Resources
  • Agent toolkit
  • Testing library

Research

  • Papers
  • Repository research

Learn

  • Guides & notes
GitHub
GameMap

On this page

Establish a baselineTrace a move from input to screenAdd one fuse and replay the routeCheck what the edit might have broken