1 个不稳定版本
| 0.1.0 | 2023年9月30日 |
|---|
#1759 in 命令行实用工具
62KB
401 行
Fentrail
关于
Fentrail 是一套工具(Rust 库、CLI 和 HTTP 服务器),用于调查棋局可能经过的路径以达到特定位置。系统的流程由两个独立的组件组成。首先,使用 CLI,通过处理用户提供的 PGN 格式的游戏数据库生成键值存储。其次,通过 HTTP 请求或通过 FEN 输入从命令行查询生成的存储。
安装
假设您已安装 Rust,则可以从 https://crates.io 安装 fentrail CLI 和 serveft HTTP 服务器。
cargo install fentrail
cargo install serveft
用法
两个 CLI 子命令及其选项和参数都使用提供的 --help 标志进行了文档记录。
$ fentrail --help
Usage: fentrail <command> [<args>]
Build and query opening lookup tables for chess positions.
Options:
--help display usage information
Commands:
pack Initiate or populate KV-stores.
ask Inquire a store about a specific position.
$ fentrail pack --help
Usage: fentrail pack <pgn> [-d <depth>] [-e <ecotsv>] [-o <outdir>]
Initiate or populate KV-stores.
Positional Arguments:
pgn path to the game database in PGN format
Options:
-d, --depth moves from each side to process in a game [default: 12]
-e, --ecotsv path to a tsv file to be used as an ECO
-o, --outdir directory to store the fentrail database [default: $PWD]
--help display usage information
$ fentrail ask --help
Usage: fentrail ask <fen> [-s <store>]
Inquire a store about a specific position.
Positional Arguments:
fen FEN string to query
Options:
-s, --store path to the fentrail database [default: $PWD/fentrail.redb]
--help display usage information
pack 命令不会覆盖现有存储,而是从新的 PGN 输入添加未见过的 (位置, 开局) 对。如果适合您的用例,您始终可以在调用 pack 之前手动删除旧数据库。
如果您想为 pack 提供自定义的 ECO,则它必须是一个至少有两列的 TSV 文件 - name 和 pgn。您可以检查捆绑的 ECO 作为示例。
serveft 命令不接受任何额外的参数 - 而是可以通过环境变量进行配置。
SERVEFT_PORT:通过该端口号提供 HTTP 请求 - 默认8000SERVEFT_STORE:查询 fentrail 数据库的路径 - 默认$PWD/fentrail.redb
运行后,您可以通过 FEN 负载向服务器发送 POST 请求。
SERVEFT_PORT=3000 SERVEFT_STORE=/var/db/fentrail.redb serveft &
curl -sS 0.0.0.0:3000 -d 'rnbq1rk1/ppp1ppbp/3p1np1/8/2PPP3/2N2N1P/PP3PP1/R1BQKB1R b KQ - 0 6'
致谢
许可证
属于 Fentrail 工作区的每个包都根据自由软件基金会发布的 GNU Affero 通用公共许可证进行授权,许可证版本为 3 或(根据您的选择)任何更高版本。有关详细信息,请参阅COPYING 文件。
依赖项
~6.5MB
~119K SLoC