定制 kesty/uci-chess 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kesty/uci-chess

最新稳定版本:v1.0.0

Composer 安装命令:

composer require kesty/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 kesty/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();

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固