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 ofLevelobjects, each containing sprite placements and configuration data. - Constants
Define game-wide constants for colors, grid size, and gameplay parameters. - Game Class
Create a class extendingARCBaseGamethat 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
Createmetadata.json:
| Field | Description |
|---|---|
game_id | Unique identifier in format {4-char game ID}-{version} |
default_fps | Frames per second for playback (optional) |
baseline_actions | Array of average action counts per level (optional) |
tags | Optional tags for categorization |
local_dir | Relative path to game directory |
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 extendsARCBaseGame 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:.clone()- Creates independent copy of template.color_remap(None, color)- Changes all pixels to random color.set_scale(scale)- Applies the random scale.set_position(x, y)- Places at random position in the grid
Level Initialization
Theon_set_level() method is called when a level loads:
Win Condition
Define when the player wins:Game Loop
Thestep() method contains the main game logic.
Action Flow
- Check action type:
GameAction.ACTION6is the click action - Get coordinates: Extract
x,yfromaction.data - Convert coordinates:
display_to_grid()handles camera scaling - Find sprite: Check if click hit any sprite
- Remove sprite: Update level state
- Check win: Advance to the next level or win the game on the last level if condition is met
- Complete action: Always call
self.complete_action()
Testing the Game
Run the game using the ARC-AGI-3 client:Complete Code
Full ab12.py source code
Full ab12.py source code

