Skip to content

Instantly share code, notes, and snippets.

@rndmcnlly
Created May 2, 2024 23:47
Show Gist options
  • Save rndmcnlly/65c7977955c0442cebf60ae8f82e3d47 to your computer and use it in GitHub Desktop.
Save rndmcnlly/65c7977955c0442cebf60ae8f82e3d47 to your computer and use it in GitHub Desktop.

Prompt:

You are an automated playtesting agent for PICO-8 games. Your goal is to exercise the game's most important functionality. You can take action to control the videogame by outputting Lua code inside of a ... tag. After sending a message containing code, wait for a reply containing <lua_result>...</lua_result> blocks indicating the text of any printed results from your code's execution. In your Lua code, you have access to all of the normal PICO-8 API plus the following functions: _step() -- run the game's main loop for one iteration _set_btn(isDown, i) -- controls the simulated state of a button (influences calls to btn(i)) Briefly explain the reasoning behind each chunk of Lua code you generate and what you would expect to see in the visual result (if you could see). Because you are a text-based agent, you'll need to make sure your code generates textual output to verify that your code had the desired effects. In PICO-8, the print function only takes one argument, so you may need to manually concatenate message fragments. For reference, here is the game's source code: <game_source_code> -- Player properties player = { x = 64, -- Initial horizontal position y = 120, -- Initial vertical position (bottom of the screen) speed = 2 -- Movement speed } -- Game initialization function _init() cls() -- Clear the screen end -- Game update loop function _update() -- Move player left if (btn(0)) then player.x -= player.speed end -- Move player right if (btn(1)) then player.x += player.speed end -- Keep player within screen bounds player.x = mid(0, player.x, 127) end -- Game drawing loop function _draw() cls() -- Clear the screen rectfill(player.x - 4, player.y - 4, player.x + 4, player.y + 4, 8) -- Draw player as a square end </game_source_code>

Response:

To begin playtesting the provided PICO-8 game, I will initiate a sequence of actions designed to test the basic functionalities—especially player movement and boundary constraints. Here's the step-by-step reasoning for each Lua code block that will be executed.

1. Test Initialization

First, I'll ensure that the game initializes correctly, which sets the player at the specified starting position. The output should confirm that the player starts at x = 64, y = 120.

lua<lua>
_init()
print("Initial X:"..player.x..", Y:"..player.y)
</lua>

2. Test Movement Left

Next, I'll test the player's ability to move left. I will simulate pressing the left button (button 0), update the game state, and then check if the player's x-coordinate decreases by the player's speed.

lua<lua>
_set_btn(true, 0)
_step()
_set_btn(false, 0)
print("Moved Left X:"..player.x)
</lua>

3. Test Movement Right

Similarly, I will test moving the player right. I will simulate pressing the right button (button 1), update the game state, and then check if the player's x-coordinate increases as expected.

lua<lua>
_set_btn(true, 1)
_step()
_set_btn(false, 1)
print("Moved Right X:"..player.x)
</lua>

4. Test Boundary Constraint

Finally, I will test the boundary constraints by attempting to move the player further right beyond the screen bounds. This will verify that the player's position does not exceed the screen width (127 pixels).

lua<lua>
-- Move player beyond right boundary
for i=1,40 do
    _set_btn(true, 1)
    _step()
    _set_btn(false, 1)
end
print("Boundary Test X:"..player.x)
</lua>

These tests will help verify the game's core functionality and ensure that the movement controls and boundary constraints are working as expected. Each piece of code is designed to trigger specific game functionality and check its outcome through printed results.

Prompt:

<lua_result> Initial X:64, Y:120 </lua_result> <lua_result> Moved Left: X:62 </lua_result> <lua_result> Moved Right: X:64 </lua_result> <lua_result> Boundary Test X:127 </lua_result>

Response:

The results from the executed Lua code indicate that the game's functionality is behaving as expected based on the provided source code:

  1. Initialization: The initial position is correctly set at X=64,Y=120X = 64, Y = 120X=64,Y=120. This matches the initial conditions specified in the game's source code.

  2. Movement Left: After simulating a press of the left button, the player's position moved from X=64X = 64X=64 to X=62X = 62X=62. This shows a decrease by 2 units, consistent with the player's speed, confirming that the left movement functionality is correct.

  3. Movement Right: After simulating a press of the right button, the player's position reset from X=62X = 62X=62 back to X=64X = 64X=64, indicating correct handling of rightward movement. This also suggests that the button press simulations and game state updates are interacting correctly.

  4. Boundary Test: The boundary test moved the player to the rightmost possible position, X=127X = 127X=127, which is the upper limit for the player's movement as defined by the game's logic to keep the player within screen bounds. This verifies that the boundary constraints are properly enforced.

These tests have successfully validated the game's fundamental mechanics under controlled inputs. If further testing is desired, such as automatic movements to test continuous left and right boundary conditions, or random button presses to simulate more organic gameplay, those can be arranged similarly.

Prompt:

Let's do some organic stuff. In PICO-8, I think you'll want rnd().

Response:

To introduce more organic and varied movements in the playtesting, we can utilize PICO-8's rnd() function. This function generates a random float between 0 and the number it's given, or between 0 and 1 if no argument is provided. We can use this to randomly decide whether to move left or right during each game update iteration.

Here's the plan for a more dynamic testing script:

Organic Movement Test

This test will run several iterations where the direction to move (left or right) is chosen randomly. After a set number of iterations, we'll print out the final position of the player to see how the random movements accumulate.

lua<lua>
_init() -- Ensure the game is initialized and starts from a clean state
-- Simulate random movements for 20 iterations
for i=1,20 do
    if rnd() < 0.5 then
        _set_btn(true, 0) -- Move left
    else
        _set_btn(true, 1) -- Move right
    end
    _step()
    _set_btn(false, 0)
    _set_btn(false, 1)
end
print("Final X after random movements:"..player.x)
</lua>

Expected Outcome

Since the movements are random, the player's final position can vary widely between different test runs. This script provides a way to see the average behavior of the game when the player is given non-deterministic inputs, mimicking a more natural playing experience. This could also help in detecting any unusual behavior or bugs that might not surface during deterministic tests.

Prompt:

<lua_result> Final X after random movements:76 </lua_result>

Response:

The result of the organic movement test shows that after 20 random left and right movements, the player's final position on the x-axis is 76. This indicates that the game successfully processed a sequence of non-deterministic inputs, adjusting the player's position accordingly within the game's constraints.

This kind of test is useful for observing how the game handles more unpredictable player behavior. It can help in identifying potential issues with movement logic or boundary conditions that might not be apparent during standard, predictable tests.

If further testing is desired, such as increasing the number of iterations, testing other game mechanics, or even integrating scenarios where multiple buttons are pressed simultaneously, those can also be set up to provide a deeper look at the game's robustness under varied conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment