Skip to content

eee555/ms-toollib

Repository files navigation

English | 中文

ms_toollib & EVF Format

ms_toollib crates.io npm PyPI

扫雷算法工具箱 — 跨平台、多语言绑定的扫雷核心算法库。

API 文档:docs.rs/ms_toollib


总览 Architecture

base/          — 核心算法(纯 Rust)
  ├── c/       — C FFI 绑定(MSVC)
  ├── java/    — Java JNI 绑定(JDK ≥ 21)
  ├── wasm/    — WASM 绑定(wasm-pack → npm)
  └── python_package/ — Python 绑定(maturin → PyPI)

各绑定层将 base/ 编译为对应语言的 native 库,零运行时开销。


快速上手 Quick Start

Rust

[dependencies]
ms_toollib = "1.5"
use ms_toollib::{laymine, cal_bbbv};

let board = laymine(16, 30, 99, 0, 0);
println!("3BV: {}", cal_bbbv(&board));

Python

pip install ms-toollib
from ms_toollib import laymine, cal_bbbv

board = laymine(16, 30, 99)
print("3BV:", cal_bbbv(board))

JavaScript / TypeScript (bundler)

npm install ms-toollib
import { laymine, calBBBV } from "ms-toollib";

const board = laymine(16, 30, 99, 0, 0);
console.log("3BV:", calBBBV(board));

Node.js

npm install ms-toollib@alpha

C (Windows, MSVC)

cd c && cargo build --release
# 示例见 demos/c/

Java (JDK ≥ 21)

cd java && build.bat "C:\Path\to\jdk-21"
import ms_toollib.*;

var board = MsToollib.laymine(16, 30, 99, 0, 0);
System.out.println("3BV: " + MsToollib.cal3BV(board));

try (var video = new EvfVideo("replay.evf")) {
    video.parse();
    var data = video.getData();
    System.out.println(data.getPlayer() + " " + data.getRtime());
}

C++ (Linux, CMake + Corrosion)

cd c++ && cmake -B build . && make -C build -j4
#include "cxxbridge_code/src/lib.rs.h"

int main() {
    rust::Box<AvfVideo> v = new_AvfVideo("replay.avf");
    v->parse();
    v->analyse();
    std::cout << "player: " << v->get_player() << std::endl;
    std::cout << "3BV: " << v->get_bbbv() << std::endl;
}

Julia(通过 Python 绑定)

pip install ms-toollib
using PyCall
ms = @pyimport ms_toollib

board = ms.laymine(16, 30, 99)
println("3BV: ", ms.cal_bbbv(board))

v = ms.AvfVideo("replay.avf")
v.parse()
v.analyse()
println(v.player_identifier)
julia demos/julia/callms_toollib.jl

功能 Features

功能 说明
埋雷 无猜埋雷(筛选法 + 调整法)
指标计算 3BV / ZiNi / ISL / OP
概率计算 基于当前局面的逐格雷概率
状态机 逐步骤推衍局面变化
录像解析 支持 AVF / EVF / MVF / RMV 格式
局面识别 图片输入 → 识别局面(需 rspy feature)
录像分析 效率指标、pluck 检测、跳判检测

版本号

平台 最新版本 发布渠道
Rust crate 1.5.10 crates.io
Python 1.5.10 pip install ms-toollib
WASM (bundler) 1.5.10 npm install ms-toollib
WASM (Node.js) 1.5.10-alpha npm install ms-toollib@alpha
C 0.1.0 源码编译
C++ 0.1.0 源码编译(Corrosion + CXX)
Java 1.5.10 源码编译(JNI)

Python 支持平台

Python >= 3.7, <= 3.12:

  • Windows: x86, x64
  • Linux: x86, x86_64, aarch64, armv7, ppc64le, s390x
  • macOS: x86_64, aarch64

构建依赖

目标 运行时 构建工具
Rust rustup + cargo
Python maturin(pip 安装)
WASM wasm-pack(cargo install)
C (Windows) MSVC(VS 2022)+ cargo
Java JDK ≥ 21(含 jni.h)+ MSVC + cargo

所有平台都需 Rust 工具链编译核心库。Python / JS / WASM 有预编译包可直接 pip / npm install


目录说明

├── base/              # 核心库(features: rs, py, js)
│   ├── src/
│   │   ├── algorithms/   # 求解、概率、OCR
│   │   ├── videos/       # 录像解析 + 状态机
│   │   └── ...
│   └── tests/
├── c/                 # C FFI(staticlib)
│   ├── include/ms_toollib/  # C 头文件
│   ├── src/lib.rs          # extern "C" 桥接
│   └── tests/
├── java/              # Java JNI 绑定
│   ├── src/main/java/ms_toollib/  # Java 类
│   └── src/main/c/jni_wrapper.c   # JNI 胶水
├── wasm/              # WASM 绑定(wasm-bindgen)
├── python_package/    # Python 绑定(pyo3 / maturin)
├── demos/             # 各语言示例
│   ├── c/
│   ├── java/
│   └── ...
└── test_files/        # 示例录像文件

开发

git clone https://github.com/eee555/ms_toollib.git
cd base

# 运行测试
cargo test --features rs

# 构建 C 绑定
cd ../c && cargo build --release

详细见 CONTRIBUTING.md


相关项目


License

MIT

About

Algorithms for minesweeper, published on various platforms.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors