Skip to main content
This example walks through a simple game where randomly generated sprites appear and the player must click to remove them all to win. See the full code

Game File Structure

Each game adheres to the following structure:
  • Imports
    Import ARCEngine classes and any standard library modules needed.
  • Sprite Definitions
    Define sprite templates in a dictionary. Sprites are objects with a name, rectangular pixel array, and optional tags.
  • Level Definitions
    Define levels as a list of Level objects, each containing sprite placements and configuration data.
  • Constants
    Define game-wide constants for colors, grid size, and gameplay parameters.
  • Game Class
    Create a class extending ARCBaseGame that implements game logic. The class name must match the 4-character game ID with the first letter capitalized.

Directory Structure

To start building your own environment, create the following directory structure:

Metadata File

Create metadata.json:

Imports and Constants

Start with the imports and constants:

Sprite and Level Definitions

Define the sprites and levels for your game.
In this example, the base sprite template that will be cloned and modified during generation:

Game Class Definition

The game class extends ARCBaseGame and accepts a seed parameter:

Gameplay Logic and Mechanics

This game generates sprites by cloning from the sprite dictionary and applying random properties:

Generation Pattern

The method chains operations on the cloned sprite:
  1. .clone() - Creates independent copy of template
  2. .color_remap(None, color) - Changes all pixels to random color
  3. .set_scale(scale) - Applies the random scale
  4. .set_position(x, y) - Places at random position in the grid
These can be used in level definitions directly for static levels.

Level Initialization

The on_set_level() method is called when a level loads:
This method triggers sprite generation each time the level is set or reset.

Win Condition

Define when the player wins:

Game Loop

The step() method contains the main game logic.

Action Flow

  1. Check action type: GameAction.ACTION6 is the click action
  2. Get coordinates: Extract x, y from action.data
  3. Convert coordinates: display_to_grid() handles camera scaling
  4. Find sprite: Check if click hit any sprite
  5. Remove sprite: Update level state
  6. Check win: Advance to the next level or win the game on the last level if condition is met
  7. Complete action: Always call self.complete_action()

Testing the Game

Run the game using the ARC-AGI-3 client:
If you’d like to see a 100-step run on your game, play the game with the Sample Agent.

Complete Code

Further Reading

For more information, refer to the ARC Engine Documentation.