Commit fc25e15a authored by nanahira's avatar nanahira

readme

parent 34fc29ff
...@@ -28,14 +28,19 @@ let db: Database; ...@@ -28,14 +28,19 @@ let db: Database;
let constantDict = new Map<string, number>(); let constantDict = new Map<string, number>();
async function loadConstants() { async function loadConstants() {
const commonContent = await fs.promises.readFile("./ocgcore/common.h", "utf-8"); try {
for (let lineRaw of commonContent.split("\n")) { const commonContent = await fs.promises.readFile("./ocgcore/common.h", "utf-8");
const line = lineRaw.trim(); for (let lineRaw of commonContent.split("\n")) {
const match = line.match(/^#define ([_A-Z0-9]+)\t+(0x[0-9a-fA-F]+)/); const line = lineRaw.trim();
if (match) { const match = line.match(/^#define ([_A-Z0-9]+)\t+(0x[0-9a-fA-F]+)/);
constantDict.set(match[1], parseInt(match[2])); if (match) {
constantDict.set(match[1], parseInt(match[2]));
}
} }
} catch (e) {
console.error(`Load dict failed: ${e.toString()}`);
} }
} }
function joinWithAnd(clauses: string[]) { function joinWithAnd(clauses: string[]) {
......
upper: 100000000 upper: 100000000
lower: 0 lower: 0
where: where:
- "1" - "type & {TYPE_MONSTER} > 0"
mayIncorrectStatements: mayIncorrectStatements:
- incorrectCount: 4 - incorrectCount: 4
lessThanOrEqual: true lessThanOrEqual: true
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
"name": "card-guesser", "name": "card-guesser",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "build/guess.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "build": "tsc",
"start": "node build/guess.js"
}, },
"author": "", "author": "Nanahira",
"license": "ISC", "license": "AGPL-3.0",
"dependencies": { "dependencies": {
"@types/node": "^14.14.9", "@types/node": "^14.14.9",
"@types/underscore": "^1.10.24", "@types/underscore": "^1.10.24",
......
# Card guesser # YGOPro 猜卡器
a simple tool for guessing cards by bisection. 应对 ~~iDuel~~ 群里的猜卡游戏而设计的猜卡器
支持直接按搜索条件猜卡,也支持~~内鬼用的~~按模糊逻辑,即固定数量的条件可能是错误的情况下,猜卡。
## 需要的资源文件
* `cards.cdb` 从 YGOPro 目录复制即可。
* `ocgcore` 从 https://github.com/Fluorohydride/ygopro-core 获取,并改名为 `ocgcore` 放在本目录下。
## 如何使用
* `npm ci && npm run build`
* 复制 `info.example.yaml``info.yaml` 下,并填写相关的搜索条件。
为了方便填写,卡片种类以及种族属性等字段,可以填写别名,即 `{TYPE_MONSTER}` `{RACE_MACHINE}` 等,与 YGOPro 的脚本引擎常量一致。
* `npm start` 列出所有可行集,并给出卡片密码的中位数,可以按照中位数询问游戏举办方进行二分查找。
## info.yaml 的格式
```yaml
upper: 100000000
lower: 0
where:
- "type & {TYPE_MONSTER} > 0"
mayIncorrectStatements:
- incorrectCount: 4
lessThanOrEqual: true
where:
- "type & {TYPE_FUSION} = 0"
- "type & {TYPE_SYNCHRO} > 0"
- "type & {TYPE_XYZ} > 0"
- "type & {TYPE_LINK} > 0"
```
参数如下。
* `upper` 卡号上界,用于二分定卡号。**模糊逻辑规则下请保持该字段默认,并把卡号条件填写在模糊逻辑的字段内。**
* `lower` 卡号下界,用于二分定卡号。
* `where` 约束条件,使用 SQL 语句填写,相互之间是 AND 的关系。
### 模糊逻辑
`mayIncorrectStatements` 为模糊逻辑字段,非模糊逻辑规则可以删除该字段以不使用模糊逻辑查找。
模糊逻辑为数组,可以指定多组模糊逻辑查询,相互之间是 AND 的关系。
每一组模糊逻辑条件包含字段意义如下。
* `incorrectCount` 错误条件个数。
* `lessThanOrEqual` 若为 true,则错误条件为小于该数量个。若为 false,则错误条件数量为准确数量。
* `where` 约束条件,使用 SQL 语句填写。其中有一定数量的错误条件。
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment