LLM-Assisted FPS Prototyping: Prompt Design and a Practical Validation Checklist

    Learn how to use large language models to build a playable first-person shooter prototype without treating generated code as production-ready. This guide covers capability boundaries, prompt structure, modular generation, mission state-machine implementation, automated tests, integration practices, troubleshooting, and deployment risks.

    1. Capability Boundaries and Tool Selection

    During game prototyping, large language models are most useful for quickly producing well-structured code drafts, scene descriptions, and configuration tables. They cannot determine whether a game mechanic is fun, nor can they guarantee that generated code will run directly on your specific engine version. The workflow used in this article is therefore straightforward: the model produces drafts, while the developer defines the goals, runs tests, and makes the final decisions.

    The original practice does not identify the model name or version, so this article does not speculate. When running your own experiments, record the model name, version, invocation date, and prompts in PROMPTS.md at the project root. The same prompt can produce significantly different results across model versions. Complete records are necessary for others to reproduce your results.

    There are three common approaches:

    1. Ask the model to generate the entire project in one pass.
    2. Generate the project module by module and integrate the results manually.
    3. Use the model only for design discussions.

    Generating the entire project at once produces a large amount of code, making errors difficult to isolate. It is suitable mainly for a quick visual demonstration. Generating modules separately allows each step to be tested independently and is more appropriate for a prototype that will be maintained over time. This article recommends the second approach.

    2. Write the Prompt First: Define the Game Loop

    The first step in prompt design is to define the game loop: what the player does, what the objective is, and how the player can fail. If you describe only the visuals first, the model may produce an attractive static scene without a playable structure. Failure conditions are especially important. Without them, the model may invent its own rules, making later alignment with the design difficult.

    The following template can be adapted directly:

    1. Role: You are an engineer familiar with Node.js and game loops.
    2. Project: A first-person shooter prototype mission system set in a fictional port lockdown area. Do not use real-world weapon specifications.
    3. Core gameplay: The player completes six stages in order: infiltrate, cut_relay_1, cut_relay_2, cut_relay_3, break_blockade, evacuate.
    4. Win condition: All stages are completed in order.
    5. Failure conditions: Health reaches 0, or the time limit is exceeded.
    6. Interface contract: The mission module interacts with the engine only through a hooks object. hooks contains updateHUD, spawnEnemies, unlockArea, onFail, and onWin.
    7. Output requirements: Use ES modules, do not depend on third-party packages, include node:test unit tests, and list all assumptions you make.

    The interface contract is particularly important. The mission module communicates with the engine only through hooks, which means the same mission logic can be connected to different engines by rewriting only the adapter layer.

    3. Generate Modules Incrementally

    A recommended generation order is:

    1. Mission state machine
    2. Scene and level areas
    3. Enemy spawning and AI
    4. Weapon values
    5. HUD binding
    6. Final integration

    The reason for this order is that the mission state machine does not depend on rendering and can be tested directly from the command line. Scene generation is more difficult to validate, so it should come after the core logic has passed its tests.

    After generating each module, run its tests before moving to the next one. Do not provide all modules to the model in a single request. When a problem appears, it will otherwise be difficult to determine which layer caused it.

    Scene and Level Areas

    Scene design can be divided into four steps:

    1. Describe the area list in text, such as an entrance corridor, yard, warehouse, and dock. For each area, specify its unlock condition.
    2. Ask the model to output a coordinate and dimension configuration table rather than generating scene code directly. A script can validate the table by checking that areas do not overlap, spawn points are within reachable spaces, and height differences between adjacent areas do not exceed what the character can traverse.
    3. Store lighting and material parameters in a separate configuration file. Examples include rain intensity, backlight angle, and ground reflectivity. This makes repeated adjustments possible without changing the code.
    4. Save a screenshot after each generation and compare it with a fixed reference image. Style drift often develops gradually over multiple revisions and can be difficult to notice when reviewing only the latest result.

    Enemy Spawning and AI

    Prompts for enemy behavior should specify boundary conditions rather than leaving them for the model to guess. At a minimum, define:

    • What happens when a path is unreachable
    • Whether an enemy continues tracking the player when its line of sight is blocked
    • How long an enemy waits before returning to patrol after losing the target
    • The maximum number of enemies that can exist in one area at the same time

    Hit detection and damage calculations should use a fixed random seed during testing. This ensures consistent results between runs and makes it easier to compare changes in game values.

    Weapon Values

    During the prototype stage, use placeholder weapon values and store them in a separate configuration file. The values should come from your own design documentation rather than being generated from the model’s general knowledge.

    Two rules should be explicitly tested:

    • Shooting has no effect and does not reduce ammunition when the magazine is empty.
    • Shooting is disabled while reloading.

    HUD Binding

    The HUD should display health, ammunition, the current stage, and the remaining time. HUD updates should be driven by the mission module’s tick method rather than manually assembling strings in every event handler.

    The mission module should provide the values, while the HUD should only display them. This prevents the same data from being modified in two places, which could cause the interface and the actual game state to diverge.

    4. Mission State Machine: Runnable Code

    The following code is a complete mission state-machine implementation with no third-party dependencies. It requires Node.js 18 or later.

    Project structure:

    1. prototype/
    2. mission.js
    3. mission.test.js

    Run the tests with:

    1. node --test

    Contents of mission.js:

    1. export const STAGES = [
    2. "infiltrate",
    3. "cut_relay_1",
    4. "cut_relay_2",
    5. "cut_relay_3",
    6. "break_blockade",
    7. "evacuate",
    8. ];
    9. export class Mission {
    10. constructor(hooks, options = {}) {
    11. for (const name of ["updateHUD", "spawnEnemies", "unlockArea"]) {
    12. if (typeof hooks?.[name] !== "function") {
    13. throw new TypeError(`hooks.${name} must be a function`);
    14. }
    15. }
    16. this.hooks = hooks;
    17. this.timeLimit = options.timeLimit ?? Infinity;
    18. this.elapsed = 0;
    19. this.index = 0;
    20. this.status = "running"; // running | won | failed
    21. }
    22. get stage() {
    23. return STAGES[this.index] ?? null;
    24. }
    25. start() {
    26. this.#enterStage();
    27. }
    28. // Call once per frame with the frame time in seconds.
    29. tick(dt, player) {
    30. if (this.status !== "running") return;
    31. this.elapsed += dt;
    32. if (player.health <= 0) return this.#fail("player_dead");
    33. if (this.elapsed >= this.timeLimit) return this.#fail("timeout");
    34. this.hooks.updateHUD({
    35. stage: this.stage,
    36. status: this.status,
    37. timeLeft: this.timeLimit - this.elapsed,
    38. });
    39. }
    40. // Call when the engine reports that the current objective is complete.
    41. completeObjective(stageName) {
    42. if (this.status !== "running") return;
    43. if (stageName !== this.stage) return; // ignore out-of-order events
    44. this.index += 1;
    45. if (this.index >= STAGES.length) return this.#win();
    46. this.#enterStage();
    47. }
    48. #enterStage() {
    49. this.hooks.unlockArea(this.stage);
    50. this.hooks.spawnEnemies(this.stage);
    51. this.hooks.updateHUD({ stage: this.stage, status: this.status });
    52. }
    53. #win() {
    54. this.status = "won";
    55. this.hooks.updateHUD({ stage: null, status: this.status });
    56. this.hooks.onWin?.();
    57. }
    58. #fail(reason) {
    59. this.status = "failed";
    60. this.hooks.onFail?.(reason);
    61. }
    62. }

    Contents of mission.test.js:

    1. import { test } from "node:test";
    2. import assert from "node:assert/strict";
    3. import { Mission, STAGES } from "./mission.js";
    4. function makeHooks() {
    5. const calls = [];
    6. return {
    7. calls,
    8. updateHUD: (state) => calls.push(["hud", state.stage ?? null, state.status]),
    9. spawnEnemies: (stage) => calls.push(["spawn", stage]),
    10. unlockArea: (stage) => calls.push(["unlock", stage]),
    11. onFail: (reason) => calls.push(["fail", reason]),
    12. onWin: () => calls.push(["win"]),
    13. };
    14. }
    15. const healthyPlayer = { health: 100 };
    16. test("completes all stages in order and wins once", () => {
    17. const hooks = makeHooks();
    18. const mission = new Mission(hooks);
    19. mission.start();
    20. for (const stage of STAGES) {
    21. mission.completeObjective(stage);
    22. }
    23. mission.completeObjective("evacuate"); // extra event after the win
    24. const wins = hooks.calls.filter(([type]) => type === "win");
    25. assert.equal(wins.length, 1);
    26. assert.equal(mission.status, "won");
    27. });
    28. test("ignores events for stages that are not active", () => {
    29. const mission = new Mission(makeHooks());
    30. mission.start();
    31. mission.completeObjective("cut_relay_2");
    32. assert.equal(mission.stage, "infiltrate");
    33. });
    34. test("fails when player health reaches zero", () => {
    35. const hooks = makeHooks();
    36. const mission = new Mission(hooks);
    37. mission.start();
    38. mission.tick(0.016, { health: 0 });
    39. assert.equal(mission.status, "failed");
    40. assert.deepEqual(hooks.calls.at(-1), ["fail", "player_dead"]);
    41. });
    42. test("fails on timeout and stops accepting events", () => {
    43. const hooks = makeHooks();
    44. const mission = new Mission(hooks, { timeLimit: 1 });
    45. mission.start();
    46. mission.tick(1.5, healthyPlayer);
    47. mission.completeObjective("infiltrate");
    48. assert.equal(mission.status, "failed");
    49. assert.equal(mission.stage, "infiltrate");
    50. assert.deepEqual(hooks.calls.at(-1), ["fail", "timeout"]);
    51. });

    When connecting the module to a real engine, write adapter functions for updateHUD, spawnEnemies, unlockArea, and the other hooks, then call tick from the engine’s main loop. Collision events or objective-completion events from the engine should call completeObjective. Event names should match the stage names in STAGES.

    5. Validation Checklist

    Before integrating each module, review the following items:

    • Mission stages advance in order, and out-of-order events are ignored.
    • onWin is called only once.
    • No events are accepted after failure.
    • A timeout triggers onFail("timeout").
    • Health reaching 0 triggers onFail("player_dead").
    • The HUD is refreshed whenever the stage changes.
    • Enemy counts remain within the configured limit.
    • Shooting has no effect when ammunition is empty, and ammunition never becomes negative.
    • After adjusting values, play through the entire flow at least once.
    • Compare screenshots with the reference image and confirm that there is no obvious style drift.

    The first five items can be automated and placed in the test file. The later items require manual review because they involve player experience and visual judgment.

    6. Common Errors and Troubleshooting

    Symptom Possible cause Recommended action
    A stage is skipped Event names do not match stage names Reference the STAGES constant for event names instead of writing string literals manually
    Victory is triggered multiple times Both tick and completeObjective handle completion logic Check the status guards and ensure that end-state logic runs only once
    The scene is visible but cannot be traversed Area coordinates overlap, or the height difference exceeds the character’s traversal ability Run the configuration-table validation script and correct conflicting data
    Enemies become stuck in corners No fallback behavior exists for unreachable paths Require fallback behavior in the prompt and add corresponding tests
    HUD values do not update The engine’s main loop does not call tick Confirm the call in the engine’s frame callback and add logging
    The interface changes after regeneration The interface contract was not fixed Include the hooks interface in the prompt and run tests after every generation

    Most problems can be located quickly through testing. If an issue involves multiple modules, separate the modules, validate them independently, and then merge them step by step.

    7. Compliance and Deployment Risks

    Model-generated code must undergo human review before entering a release branch, especially code related to input handling, network requests, and file access. Unreviewed code should not be deployed directly.

    Licenses for art, music, and fonts must be verified. Model-generated assets also require copyright review; they should not be assumed to be commercially usable by default.

    For military-themed content, avoid real weapon specifications, real military force structures, and tactical details that could be directly reused. A fictional setting and placeholder values are sufficient for prototype validation. Before publishing, also review the content against the rules of the target platform.

    When deploying to a cloud platform, store access keys in environment variables or a secret-management service. Do not place them in source code or commit them to a repository. Use the principle of least privilege for accounts. After a demonstration, promptly delete unused object-storage buckets and container instances to avoid ongoing charges and prevent data from remaining publicly exposed.