PHPackages                             aminyazdanpanah/rush-hour-solver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aminyazdanpanah/rush-hour-solver

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

aminyazdanpanah/rush-hour-solver
================================

🚗 Rush Hour Game Solver

v0.1.0(3y ago)011MITPHPPHP ^8.1

Since Aug 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/aminyazdanpanah/Rush-Hour-Solver)[ Packagist](https://packagist.org/packages/aminyazdanpanah/rush-hour-solver)[ Docs](https://github.com/aminyazdanpanah/Rush-Hour-Solver)[ RSS](/packages/aminyazdanpanah-rush-hour-solver/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

🚗 Rush Hour Solver in PHP
=========================

[](#-rush-hour-solver-in-php)

Rush Hour is a tiny sliding board game played on a board of 6x6 squares(it can be larger). The objective in the game is to free the red car from the surrounding traffic by sliding the cars out of the way onto free squares until the red car can drive out of the exit on the right side of the board. Note that cars can only go forward of reverse, not to the side. Use google or this video for an impression.

[![](./images/rush-hour.gif)](./images/rush-hour.gif)

**Contents**

- [Requirements](#requirements)
- [Installation](#installation)
- [Quickstart](#quickstart)
    - [Loading a Board](#loading-a-board)
    - [Solving board](#solving-board)
- [Contributing and Reporting Bugs](#contributing-and-reporting-bugs)
- [Credits](#credits)
- [License](#license)

Requirements
------------

[](#requirements)

This version of the package is only compatible with **[PHP 8.1](https://www.php.net/releases/)** or higher.

Installation
------------

[](#installation)

Install the package via **[composer](https://getcomposer.org/)**:

```
composer require aminyazdanpanah/rush-hour-solver
```

Alternatively, add the dependency directly to your `composer.json` file:

```
"require": {
    "aminyazdanpanah/rush-hour-solver": "^0.1"
}
```

Quickstart
----------

[](#quickstart)

First of all, you need to include the package in your code:

```
require 'vendor/autoload.php'; // path to the autoload file
```

### Loading a Board

[](#loading-a-board)

There two ways to load a board.

#### 1. From an array

[](#1-from-an--array)

```
use RushHourSolver\BoardLoader;

$board_array = [
    [".", ".", ".", ".", "A", "A"],
    [".", ".", "B", "B", "C", "C"],
    ["r", "r", ".", ".", "E", "F"],
    ["G", "G", "H", "H", "E", "F"],
    [".", ".", ".", "I", "E", "F"],
    [".", ".", ".", "I", "J", "J"],
];

$board_loader = new BoardLoader($board_array);
$board = $board_loader->getBoard();
```

#### 2. From a file

[](#2-from-a-file)

```
use RushHourSolver\BoardLoader;

$board_loader = new BoardLoader();
$board_loader->loadBoardFromFile("/path/to/board.txt");
$board = $board_loader->getBoard();
```

### Solving board

[](#solving-board)

```
use RushHourSolver\BoardSolver;
use RushHourSolver\Enums\Direction;
use RushHourSolver\Enums\Orientation;

$board_solver = new BoardSolver($board);
$solutions = $board_solver->getSolution();

foreach ($solutions as $index => $solution) {
    $vehicle = $solution[0];
    $direction = $solution[1];

    if ($vehicle->getOrientation() === Orientation::HORIZONTAL && $direction === Direction::FORWARD) {
        $direction_name = "Right";
    } elseif ($vehicle->getOrientation() === Orientation::HORIZONTAL && $direction === Direction::BACKWARD) {
        $direction_name = "Left";
    } elseif ($vehicle->getOrientation() === Orientation::VERTICAL && $direction === Direction::FORWARD) {
        $direction_name = "Down";
    } elseif ($vehicle->getOrientation() === Orientation::VERTICAL && $direction === Direction::BACKWARD) {
        $direction_name = "Up";
    } else {
        $direction_name = "Unknown";
    }

    echo "\n" . $index + 1 . ": " . $vehicle->getName() . " -> " . $direction_name;
}
```

### output

[](#output)

steps to solve the board

[![](./images/output.jpg)](./images/output.jpg)

Contributing and Reporting Bugs
-------------------------------

[](#contributing-and-reporting-bugs)

I'd love your help in improving, correcting, adding to the specification. Please **[file an issue](https://github.com/aminyazdanpanah/rush-hour-solver/issues)** or **[submit a pull request](https://github.com/aminyazdanpanah/rush-hour-solver/pulls)**.

- See **[Contributing File](https://github.com/aminyazdanpanah/rush-hour-solver/blob/master/CONTRIBUTING.md)** for more information.
- If you discover a security vulnerability within this package, please see **[SECURITY File](https://github.com/aminyazdanpanah/rush-hour-solver/blob/master/SECURITY.md)** for more information.

Credits
-------

[](#credits)

- **[Amin Yazdanpanah](https://www.aminyazdanpanah.com/?u=github.com/aminyazdanpanah/rush-hour-solver)**

License
-------

[](#license)

The MIT License (MIT). See **[License File](https://github.com/aminyazdanpanah/rush-hour-solver/blob/master/LICENSE)** for more information.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1422d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3193929?v=4)[Amin Yazdanpanah](/maintainers/aminyazdanpanah)[@aminyazdanpanah](https://github.com/aminyazdanpanah)

---

Tags

gamephppuzzelsrush-hourrush-hour-solverhourjamparkingrushrush-hourparking-jam

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aminyazdanpanah-rush-hour-solver/health.svg)

```
[![Health](https://phpackages.com/badges/aminyazdanpanah-rush-hour-solver/health.svg)](https://phpackages.com/packages/aminyazdanpanah-rush-hour-solver)
```

###  Alternatives

[florianv/business

DateTime calculations in business hours

362784.1k1](/packages/florianv-business)[acacha/llum

Llum (light in catalan language) illuminates your Laravel projects.

10926.1k](/packages/acacha-llum)[rupertgermann/tt_news

News - Website news with front page teasers and article handling inside.

2256.1k](/packages/rupertgermann-tt-news)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
