This document describes the high-level architecture of Roboyard.
Roboyard is an Android puzzle game where players guide robots through mazes. The game is built using Java and the Android SDK.
- Central controller for the game
- Manages screen transitions
- Handles game state
- Coordinates between components
Screens are managed through a screen ID system defined in Constants.java:
- Main Menu (0)
- Settings (2)
- Credits (3)
- Game Screen (4)
- Level Selection (5-8)
- Save/Load/History Screen (9)
See screens.md for detailed screen documentation.
- Manages the game board
- Handles robot movement
- Collision detection
- Level completion checks
- Processes user input
- Validates moves
- Updates robot positions
- Handles movement animations
- Autosave functionality
- Manual save slots
- Save state persistence
- Level progress tracking
- Handles graphics rendering
- Manages textures and sprites
- Screen transitions
- UI element drawing
- Touch input processing
- Gesture recognition
- Button interactions
- Back button handling
- Level data loading
- Image resource management
- Sound effects
- Game state serialization
The roboyard.pm.ia package contains the artificial intelligence (IA - Intelligence Artificielle) components used for solving the game and generating solutions. It consists of:
AGameState: Abstract base class for representing game statesAWorld: Abstract base class for the game worldGameSolution: Class that holds a sequence of moves that solve a puzzleIEndCondition: Interface for defining win conditionsIGameMove: Interface for representing game moves
The ricochet/ subpackage contains the concrete implementation for the Ricochet Robots game:
RRGameState: Represents a state in the Ricochet Robots gameRRGameMove: Represents a move in the game (robot movement)RRWorld: Represents the game board and its rulesRREndCondition: Defines when a puzzle is solvedRRPiece: Represents a robot piece on the boardRRGridCell: Represents a cell on the game boardRRGetMap: Helper class for loading game maps
The AI system is used by the solver (SolverDD class) to:
- Find solutions to puzzles
- Validate that generated random puzzles are solvable
- Calculate the minimum number of moves needed
- Generate hints and solutions for players
The game integrates the DriftingDroids Ricochet Robots solver (Copyright 2011-2014 Michael Henke, GPL v3) as a high-performance puzzle solver. The integration works as follows:
Board: Core game board representation with efficient bit operationsSolver(withSolverBFSandSolverIDDFSimplementations): Advanced pathfinding algorithmsSolutionandMove: Represents solutions and individual movesKeyDepthMapand variants: Optimized data structures for state space exploration
The integration between Roboyard's own AI system (roboyard.pm.ia) and DriftingDroids is managed through a bridge design pattern:
-
Bridge Component (
roboyard.eclabs.solver.SolverDD)- Implements Roboyard's
ISolverinterface - Creates and manages the DriftingDroids
BoardandSolverinstances - Translates between Roboyard's game elements and DriftingDroids' board representation
- Converts DriftingDroids
Solutionobjects into Roboyard'sGameSolutionformat
- Implements Roboyard's
-
Game Logic Layer (
roboyard.eclabs)- Uses
SolverDDthrough theISolverinterface - Handles user interaction and game state management
- Remains independent of the actual solver implementation
- Uses
-
AI Layer (
roboyard.pm.ia)- Provides game-specific classes (
RRGameMove,RRPiece, etc.) - Includes
RRGetMapto convert game elements to DriftingDroids format - Defines the solution format (
GameSolution) used by the game
- Provides game-specific classes (
-
Solver Layer (
driftingdroids.model)- Provides the core solving algorithms
- Works with its own optimized board representation
- Returns solutions in its native format
- Game creates grid elements (
GridElement) to represent the game state SolverDD.init()usesRRGetMapto convert these to a DriftingDroidsBoard- DriftingDroids solver finds solutions
SolverDD.getSolution()converts DriftingDroids moves to Roboyard's format- Game displays the solution to the player
This architecture allows Roboyard to:
- Use the efficient DriftingDroids solver while maintaining its own game logic
- Easily swap out the solver implementation if needed
- Keep the game code independent of the solver details
- Support future puzzle types by implementing new solver bridges
The DriftingDroids solver is particularly used for:
- Validating randomly generated puzzles
- Finding optimal (minimum moves) solutions
- Supporting the hint system
- Calculating puzzle difficulty
-
User Input
Input Manager → Game Manager → Current Screen → Game Logic → Render Manager -
Game State Changes
Game Logic → Game Manager → Screen Update → Render Manager -
Screen Transitions
Game Manager → Previous Screen Cleanup → New Screen Init → Render Manager
app/src/main/
├── java/roboyard/eclabs/
│ ├── GameManager.java # Game management
│ ├── GridGameScreen.java # Main game screen
│ ├── Constants.java # Game constants
│ ├── SaveGameScreen.java # Save/load/history system
│ └── solver/ # Game solver
│ ├── GameLevelSolver.java # Solver core
│ ├── ISolver.java # Solver interface
│ ├── SolverDD.java # Solver implementation of the driftingDdroids Solver
│ └── SolverStatus.java # Solver status
├── res/
│ ├── drawable/ # Game graphics
│ └── raw/ # Raw assets (e.g. audio background)
└── assets/
└── Maps/ # Level data
- Android SDK (min API 21)
- Java standard libraries
- No external game engines
- Texture pooling
- Resource caching
- State management
- Garbage collection optimization
- Sprite batching
- View recycling
- Layout optimization
- Frame rate management
- Efficient save formats
- Data compression
- Cache management
- State serialization
- Local storage only
- No sensitive data
- Basic file validation
- Error recovery
- No personal information
- No network access
- No external storage
- No permissions required
- Additional level packs
- New game mechanics
- Performance improvements
- UI/UX enhancements
- Code organization
- Documentation updates
- Testing coverage
- Resource optimization
- Game logic
- Movement validation
- State management
- Save/load/history system
- Screen transitions
- Game flow
- State persistence
- User interactions
- Gameplay testing
- Performance testing
- Device compatibility
- User experience