From 854d913f3ad4f7de0dd8f665aeb0ebb50693949b Mon Sep 17 00:00:00 2001 From: whoami Date: Sun, 20 Oct 2024 16:34:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20note/node-openbox-fix/open?= =?UTF-8?q?er.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- note/node-openbox-fix/opener.js | 107 ++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 note/node-openbox-fix/opener.js diff --git a/note/node-openbox-fix/opener.js b/note/node-openbox-fix/opener.js new file mode 100644 index 0000000..3c5c3ec --- /dev/null +++ b/note/node-openbox-fix/opener.js @@ -0,0 +1,107 @@ +"use strict"; + +const process = require("process"); +const fs = require("fs"); +const path = require("path"); +const readline = require("readline"); +const md5_module = require("./md5.js"); + +const args = process.argv.slice(2); +if (args.length < 4) { + console.log("openbox.js <输入文件> <读取起点> <读取长度> <输出文件>"); + process.exit(0); +} + +const file_path = args[0]; +const output_file_path = args[3]; +const start = args[1]; +const step = args[2]; + +if (!fs.existsSync(file_path)) { + console.log(`不存在的输入文件: ${file_path}`); + process.exit(0); +} + +async function cqdMain() { + const target = [ + "Zeb DNGMCFSXQCRH@nan", + "Iwn7D3Ol7uWKIfTC@XJ联队", + "Nisha HWJHJINPEPBB@nan", + "Rick QUJTCGUVGHIJ@nan", + "Muifa DDQVUJKRHPFF@nan", + "F=ma 9P8mcPnWs1YGE4J@樱花庄", + "<αβ>-02pjt42k@ReturnVoid", + "X]u$D[@涵虚", + "飞雪PSODKKXWP@涵虚", + "m@fAIgFUL", + "光Yvxf2hGRv1Vf@fAIgFUL", + "Pd%DGm8LH@Splay", + "Garakuta tKjEzvOfSnnJCb@Squall", + "Regulus VynkvDehqnzlqQX@Squall", + "光YLqKf5rv9EU9lnc@Squall", + "x8v rbl6@Asunder", + "
ce0Y2rz@powerless", + "Momo #L9GHU8F@Arcadia", + "aIarLKNq1noXvbv@新纪元", + "① =CHFpOe@新纪元", + "CtC7gL9JNpvNpOl@新纪元", + "天依 'i[8S`Aw@LuoTianyi", + "HQWWJYUHIGAVNP@霛雲", + "vRuH:z@耗子尾汁", + "咲恋 ZPSFFQXQ@公主连结", + "大油包 #PXDHVJAT@暗黑突击", + "史莱德 #XPMTVPKY@暗黑突击", + "癌细胞 Qgu35DIL[Q8us/3@TigerStar", + "gnHHXmi@TigerStar", + "wt(zEe]T@TigerStar", + "JDHYM8TC8BZEKCN@云剑", + "`I!.lf@紫微垣", + ]; + const run_prefix = "!test!\n\n{ply}\n\n{tgt}"; + const fileStream = fs.createReadStream(file_path); + const rl = readline.createInterface({ + input: fileStream, + crlfDelay: Infinity, + }); + var ln = 0; + var stamp = 0; + var sm; + var cnt; + var scr; + for await (const line of rl) { + ln += 1; + if (ln >= start && stamp == 0) { + stamp = 1; + } + if (stamp - 1 >= step) { + break; + } + if (stamp > 0) { + stamp += 1; + if (line.trim() === "") { + continue; + } + sm = 0; + cnt = 0; + console.log(`${line}:`); + for (let cur of target) { + if (cur == line) { + continue; + } + cnt += 1; + const runs = run_prefix.replace(/\{ply\}/g, line).replace(/\{tgt\}/g, cur); + const result = await md5_module.win_rate(runs, 2 * 100); + sm += result.win_count / 2; + console.log(`${cur} ${result.win_count / 2}%`); + } + scr = (sm / cnt).toFixed(2); + console.log(`平均胜率: ${scr}%\n`); + if (scr > 39) { + fs.appendFileSync(output_file_path, `${line} ${scr}\n`); + } + } + } +} + +cqdMain();