aminyazdanpanah/rush-hour-solver
最新稳定版本:v0.1.0
Composer 安装命令:
composer require aminyazdanpanah/rush-hour-solver
包简介
🚗 Rush Hour Game Solver
README 文档
README
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.
Contents
Requirements
This version of the package is only compatible with PHP 8.1 or higher.
Installation
Install the package via composer:
composer require aminyazdanpanah/rush-hour-solver
Alternatively, add the dependency directly to your composer.json file:
"require": { "aminyazdanpanah/rush-hour-solver": "^0.1" }
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
There two ways to load a board.
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
use RushHourSolver\BoardLoader; $board_loader = new BoardLoader(); $board_loader->loadBoardFromFile("/path/to/board.txt"); $board = $board_loader->getBoard();
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
steps to solve the board
Contributing and Reporting Bugs
I'd love your help in improving, correcting, adding to the specification. Please file an issue or submit a pull request.
- See Contributing File for more information.
- If you discover a security vulnerability within this package, please see SECURITY File for more information.
Credits
License
The MIT License (MIT). See License File for more information.
aminyazdanpanah/rush-hour-solver 适用场景与选型建议
aminyazdanpanah/rush-hour-solver 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 10 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「jam」 「parking」 「hour」 「rush」 「rush-hour」 「parking-jam」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aminyazdanpanah/rush-hour-solver 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aminyazdanpanah/rush-hour-solver 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aminyazdanpanah/rush-hour-solver 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DateTime calculations in business hours
This is a Kohana Auth driver, for Jam
Closuretable behavior
A Jam Field to transparently use 'monetary' as a jam field, and have currency exchange arithmetic out of the box
Jam Taxonomy
Promotions for Purchases
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-17

