chris-moreton/uci-chess
Composer 安装命令:
composer require chris-moreton/uci-chess
包简介
Wrappers to run UCI chess engines, matches and tournaments
README 文档
README
PHP wrapper classes for interfacing with UCI chess engines.
Getting started
From the root of your application
composer require chris-moreton/uci-chess
Unless using a framework where autoloading is already taken care of, you'll need to
include 'vendor/autoload.php';
Then, include the classes that you want to use, e.g.
use Netsensia\Uci\Engine;
use Netsensia\Uci\Match;
use Netsensia\Uci\Tournament\RoundRobin;
Search for a move
$engine = new Engine();
// Native application or Jar file?
$engine->setApplicationType(Engine::APPLICATION_TYPE_JAR);
// The location of the chess engine on the local file system
// You can download my engine, RivalChess from https://github.com/chris-moreton/rival-chess-android-engine/tree/master/dist
// If the engine requires any parameters, simply add them after the path
$engine->setEngineLocation('/path/to/engine.jar [params]');
// Set engine parameters
$engine->setMode(Engine::MODE_NODES);
$engine->setModeValue(100000);
// Set the starting position of the match (before any moves have been played)
$engine->setPosition(Engine::STARTPOS);
// Send the move history and get the move
$move = $engine->getMove('e2e4 d7d5');
// Important! - remove the process
$engine->unloadEngine();
Run a match
$whiteEngine = new Engine('/path/to/engine1.jar');
// No reason why you can't use the same engine if you want to test against different parameters
$blackEngine = new Engine('/path/to/engine2.jar');
$whiteEngine->setMode(Engine::MODE_NODES);
$whiteEngine->setModeValue(100);
$whiteEngine->setApplicationType(Engine::APPLICATION_TYPE_JAR);
$whiteEngine->setLogEngineOutput(false);
$blackEngine->setMode(Engine::MODE_NODES);
$blackEngine->setModeValue(10000);
$blackEngine->setApplicationType(Engine::APPLICATION_TYPE_JAR);
$blackEngine->setLogEngineOutput(false);
$match = new Match($whiteEngine, $blackEngine);
$result = $match->play();
echo $result['fen'] . PHP_EOL;
switch ($result['result']) {
case Match::DRAW: echo 'Draw';
break;
case Match::WHITE_WIN: echo 'White win';
break;
case Match::BLACK_WIN: echo 'Black win';
break;
}
$whiteEngine->unloadEngine();
$blackEngine->unloadEngine();
Run a tournament
$tournament = new RoundRobin();
// for each engine...
$engine = new Engine('/path/to/engine1.jar');
$engine->setMode(Engine::MODE_NODES);
$engine->setModeValue(100);
$engine->setApplicationType(Engine::APPLICATION_TYPE_JAR);
$engine->setLogEngineOutput(false);
$engine->setName('Engine 1');
$tournament->addEngine($engine);
...
foreach ($tournament->matches() as $match) {
echo $match->getWhite()->getName() . ' v ' . $match->getBlack()->getName() . PHP_EOL;
$tournament->play($match);
$echo $tournament->table();
}
$tournament->showTable();
$tournament->close();
chris-moreton/uci-chess 适用场景与选型建议
chris-moreton/uci-chess 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 53 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 10 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 chris-moreton/uci-chess 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chris-moreton/uci-chess 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 53
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-05