A small object-oriented implementation of a 6×6 parking puzzle in Pharo 13.1, with ASCII rendering and SUnit tests.
# Parking Game in Pharo Small Pharo 13.1 implementation of a 6x6 parking puzzle. The project focuses on the domain model, movement rules, tests, and an ASCII representation. ## Requirements Pharo 13.1. ## Problem The parking contains vehicles placed on a fixed 6x6 board. Each vehicle occupies consecutive cells. The target vehicle must reach the bottom exit located at column 4. ## Rules - Horizontal vehicles move only horizontally. - Vertical vehicles move only vertically. - Vehicles cannot overlap. - Vehicles cannot leave the 6x6 parking. - Multi-cell moves cannot jump over obstacles. - The target must reach the bottom exit at column 4. ## Assumptions - Coordinates are 1-based. - `Point x = column`, `Point y = row`. - Positive horizontal displacement means right. - Negative horizontal displacement means left. - Positive vertical displacement means down. - Negative vertical displacement means up. - All vehicle lengths are positive integers. - The target is considered solved when it reaches the bottom boundary at the exit. - The target is not physically modeled outside the board. - No solver is included. ## Design - `ParkingVehicle` -> vehicle identity, anchor position, length, orientation, and geometry. - `Parking` -> puzzle state, placement validation, movement rules, target rules, and solved-state query. - `ParkingAsciiRenderer` -> text representation. - `ParkingError` -> invalid configuration or API usage. ## Installation Clone the repository, open a Pharo 13.1 image, and load the project with Metacello: ```smalltalk Metacello new baseline: 'ParkingGame'; repository: 'tonel:///absolute/path/to/parking-game-pharo/src'; load: 'Tests'. ``` ## Quick Start ```smalltalk parking := Parking target: $X. parking addVehicle: (ParkingVehicle identifiedBy: $A at: 1 @ 1 length: 2 orientation: #horizontal). parking addVehicle: (ParkingVehicle identifiedBy: $B at: 4 @ 1 length: 3 orientation: #vertical). parking addVehicle: (ParkingVehicle identifiedBy: $C at: 1 @ 3 length: 2 orientation: #horizontal). parking addVehicle: (ParkingVehicle identifiedBy: $X at: 4 @ 4 length: 2 orientation: #vertical). (ParkingAsciiRenderer on: parking) render. parking moveVehicle: $X by: 1. (ParkingAsciiRenderer on: parking) render. parking isSolved. ``` The first rendering is: ```text +------+ |AA B | | B | |CC B | | X | | X | | | +---=--+ ``` After `parking moveVehicle: $X by: 1`, the rendering is: ```text +------+ |AA B | | B | |CC B | | | | X | | X | +---=--+ ``` The move answers `true`, and `parking isSolved` answers `true`. ## Tests Run the `ParkingGame-Tests` package with SUnit. ## Scope Intentionally absent features: - GUI; - solver; - persistence; - undo/history.