geometor.arcprize.solvers.gemini_solver

Dialogue-Based ARC Puzzle Solver

Implements a structured workflow for solving ARC puzzles through conversation with LLMs, focusing on building understanding before attempting solutions.

The solver follows a systematic process:

  1. Examine training examples individually

  2. Build comprehensive observations

  3. Validate understanding through pre-testing

  4. Implement solution through standard operations

Key Features:

  • Progressive observation building

  • Code-validated pattern discovery

  • Natural language program development

  • Iterative refinement through dialogue

  • Comprehensive session logging

The solver maintains a conversation history and working grid state, allowing for cumulative understanding and step-by-step solution development.

class geometor.arcprize.solvers.gemini_solver.PuzzleSolver(puzzle: Puzzle, model_name: str = 'models/gemini-1.5-flash-002', instructions_file: str = 'gemini_instructions.md', output_dir: str = '.', max_iterations: int = 5, timestamp: str | None = None, client: GeminiClient | None = None, logger: Logger | None = None)[source]

Bases: object

Initialize the PuzzleSolver with all necessary components for solving and logging.

parameters

puzzlePuzzle

object containing all the elements of the Puzzle

model_namestr

name of the Gemini model

instructions_filestr

path to file with system instructions

output_diroptional str

default ‘.’

max_iterationsint

max loops in the test phase

timestampoptional str

in the format %y.%j.%H%M%S

clientoptional GeminiClient

pass in client with previous context

loggeroptional Logger

pass in previous logger

attributes

start_time : datetime

working_grid : Grid

solve()[source]

Main method to orchestrate the puzzle solving workflow. Returns the working grid if solution is found, None otherwise.

initialize_output_from_input() str[source]

Initialize the test output grid with a copy of the input grid.

initialize_output_by_size(width: int, height: int, color: int = 0) str[source]

Initialize the test output grid with specific dimensions.

set_pixel(row: int, column: int, color: int) str[source]

Set grid value at a specific coordinate.

set_range(row1: int, column1: int, row2: int, column2: int, color: int) str[source]

Set grid values for a range of pixels.

submit() str[source]

Submit the working grid and check for correctness against the expected output.

exception geometor.arcprize.solvers.gemini_solver.MultipleFunctionCallsError[source]

Bases: Exception

Raised when multiple function calls are detected in a single response.

exception geometor.arcprize.solvers.gemini_solver.MaxRetriesExceededError[source]

Bases: Exception

Raised when maximum retry attempts are exhausted.

exception geometor.arcprize.solvers.gemini_solver.UnknownFunctionError[source]

Bases: Exception

Raised when an unknown function is called.

exception geometor.arcprize.solvers.gemini_solver.FunctionArgumentError[source]

Bases: Exception

Raised when invalid arguments are provided to a function.

exception geometor.arcprize.solvers.gemini_solver.FunctionExecutionError[source]

Bases: Exception

Raised when a function fails during execution.