两个开源中国象棋引擎的编译
Debian 12, gcc 12.
CCStockfish编译通过,运行时没有.nnue文件。文档声称可不用NNUE, ucioption.cpp里没有Use NNUE,不可能setoption 它 false.

Pikafish,make build时自动先make net,从GitHub下载到了43MB的.nnue文件。
AI说:根据同类引擎测试数据:
- 文件大小与ELO呈正相关(每10MB约提升50-80ELO)
- 该规模文件在i7-12700H处理器上实测(6个性能核+8个能效核。20线程(性能核支持超线程,能效核不支持)主频2.7G睿频4.7G。三级缓存24MB)。“排版混乱”?怕括号嵌套还算码农吗?
- 平均计算速度:18层/秒
- 典型ELO范围:2400-2600
- 对职业棋手胜率:约65%
特级大师水平通常对应ELO 2500+,具体表现特征包括:
- 计算深度:15-20层/秒(取决于硬件)
- 局面评估误差率<5%
- 对复杂残局处理准确率>90%
我修改的ElephantEye,在N100上 9~10层/秒(单核)。据说用了NNUE后多线程很方便。N100办公状态cpu MHz 700,单核最高睿频3.4G,6M缓存,bogomips 1612.8,有avx2和avx_vnni. Advanced Vector eXtensions - Vector Neural Network Instructions, AVX512-VNNI的丐版,支持256/512位向量,但性能弱。
垂涎三尺,奈何编译出错。① “能累机器就不累人” ② 访问GitHub不快,源码降级不如gcc降级,然而11和10都编译不过。
先歇会;倒是顺路把一团乱麻的sources.list整理清爽了:
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware #deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware deb https://mirrors.aliyun.com/debian bookworm-backports main contrib non-free non-free-firmware deb https://mirrors.aliyun.com/debian bullseye main contrib deb https://mirrors.tencent.com/debian buster main contrib
Debian 12的backports,11和10加起来,apt list | wc -l 121,572个包。
deb [选项] <协议>://<镜像地址>/<发行版代号> <组件1> <组件2>
<发行版代号>:Debian 版本名称(如bookworm)或类别(如stable)<组件>:软件包分类,如main(自由软件)、contrib(依赖非自由软件)、non-free(非自由软件)
然后可以在多个gcc版本间切换:
# update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 最后面那个数是优先级,机智的我用了版本号 || 脑子不够想新数的 # update-alternatives --config g++ 有 2 个候选项可用于替换 g++ (提供 /usr/bin/g++)。 选择 路径 优先级 状态 ------------------------------------------------------------ 0 /usr/bin/g++-12 12 自动模式 * 1 /usr/bin/g++-10 10 手动模式 2 /usr/bin/g++-12 12 手动模式 # g++ -v gcc version 10.2.1 20210110 (Debian 10.2.1-6)
哦,打个补丁:
# update-alternatives --display g++ g++ - 手动模式最佳链接版本为 /usr/bin/g++-12 链接目前指向 /usr/bin/g++-10 链接 g++ 指向 /usr/bin/g++ /usr/bin/g++-10 - 优先级 10 /usr/bin/g++-12 - 优先级 12 自动模式:系统自动选择优先级(priority)最高的版本作为默认版本。
VinXiangQ基于深度学习(YOLOv5),用它来识别抓屏中的棋子,从屏幕截图看引擎可用fairy-stockfish.exe
哦哦哦,最最重要的,CCStockfish不能用皮卡鱼的.nnue文件。
补充:gcc 9也不行,最终干了脏活,用gcc 12编译出来了。bitboard.h里:
extern Bitboard SquareBB[SQUARE_NB]; constexpr Bitboard square_bb(Square s) { assert(is_ok(s)); return SquareBB[s]; }
① 修改bitboard.h,从constexpr Bitboard square_bb到文件尾,把constexpr替换为inline
② make profile-build ARCH=x86-64-avxvnni
③ 再改bitboard.h:有两个显而易见地、把constexpr替换成inline的错误:删掉inline (“累机器别累我”)
④ 再编译, pikafish 611K,鄙人的eemod 67K
~/pika/src$ pikafish
Pikafish dev-20251007-nogit by the Pikafish developers (see AUTHORS file)
go movetime 1000
info string Available processors: 0-3
info string Using 1 thread
info string NNUE evaluation using pikafish.nnue (103MiB, (25920, 2048, 15, 32, 1))
info depth 1 seldepth 3 multipv 1 score cp 13 nodes 53 nps 53000 hashfull 0 tbhits 0 time 1 pv b2e2
info depth 2 seldepth 3 multipv 1 score cp 39 nodes 103 nps 103000 hashfull 0 tbhits 0 time 1 pv b2e2
info depth 3 seldepth 4 multipv 1 score cp 68 nodes 162 nps 162000 hashfull 0 tbhits 0 time 1 pv b2e2
info depth 4 seldepth 7 multipv 1 score cp 65 nodes 506 nps 168666 hashfull 0 tbhits 0 time 3 pv h2e2 b9c7 h0g2
info depth 5 seldepth 6 multipv 1 score cp 59 nodes 636 nps 212000 hashfull 0 tbhits 0 time 3 pv h2e2 b9c7 h0g2
info depth 6 seldepth 7 multipv 1 score cp 58 nodes 2008 nps 334666 hashfull 0 tbhits 0 time 6 pv g3g4 g9e7 h0g2 b9c7
info depth 7 seldepth 9 multipv 1 score cp 49 nodes 4099 nps 455444 hashfull 0 tbhits 0 time 9 pv h2e2 h9g7 h0g2 b9c7 b0c2
info depth 8 seldepth 11 multipv 1 score cp 47 nodes 5618 nps 468166 hashfull 0 tbhits 0 time 12 pv h2e2 b9c7 h0g2 h9g7 i0h0 i9h9
info depth 9 seldepth 14 multipv 1 score cp 46 nodes 12166 nps 579333 hashfull 3 tbhits 0 time 21 pv h2e2 b9c7 h0g2 h9g7 c3c4 g6g5 i0h0 i9h9 h0h4 a9a8
info depth 10 seldepth 16 multipv 1 score cp 45 nodes 21852 nps 607000 hashfull 7 tbhits 0 time 36 pv b2e2 b9c7 b0c2 c6c5 a0b0 a9b9 b0b4 h9g7 h0g2 g6g5
info depth 11 seldepth 19 multipv 1 score cp 38 nodes 66722 nps 641557 hashfull 21 tbhits 0 time 104 pv c3c4 b7c7 b2e2 h7e7 b0c2 h9g7 h0g2 b9a7
info depth 12 seldepth 22 multipv 1 score cp 41 nodes 98351 nps 647046 hashfull 36 tbhits 0 time 152 pv c3c4 b7c7 b2e2 h7e7 b0c2 h9g7 h0g2 i9h9 c2d4 h9h3 a0b0
info depth 13 seldepth 15 multipv 1 score cp 37 nodes 111830 nps 642701 hashfull 41 tbhits 0 time 174 pv c3c4 h7c7 b2e2 c9e7 b0c2 h9g7 a0b0 b9d8 h2f2 i9h9 h0g2 h9h5
info depth 14 seldepth 20 multipv 1 score cp 42 nodes 165187 nps 655503 hashfull 60 tbhits 0 time 252 pv c3c4 b7e7 b0c2 g6g5 a0b0 b9c7 h2g2 a9b9 b2b6 h9g7 g2g5 g7h5 h0g2 g9i7
info depth 15 seldepth 26 multipv 1 score cp 40 nodes 293344 nps 665179 hashfull 109 tbhits 0 time 441 pv b2e2 b9c7 b0c2 g6g5 c3c4 h9g7 a0b0 a9b9 h0i2 g9e7
info depth 16 seldepth 25 multipv 1 score cp 38 nodes 414022 nps 663496 hashfull 158 tbhits 0 time 624 pv g3g4 h7g7 b2e2 b7e7 b0c2 b9c7 a0b0 h9i7 h0i2 i9h9 i0h0 a9a8 b0b6 h9h3 b6c6
info depth 17 seldepth 27 multipv 1 score cp 36 nodes 543449 nps 662742 hashfull 209 tbhits 0 time 820 pv g3g4 h7g7 b2e2 b7e7 b0c2 b9c7 a0b0 h9i7 h0g2 i9h9 h2i2 g6g5 b0b5 c6c5 b5c5 g5g4 c5g5 g7g8 g5g4
info depth 18 seldepth 27 multipv 1 score cp 39 lowerbound nodes 661090 nps 661090 hashfull 253 tbhits 0 time 1000 pv g3g4
bestmove g3g4 ponder h7g7
g3g4是兵三进一。
setoption name Threads value 4
info string Using 4 threads
go movetime 1000
info string Available processors: 0-3
info string Using 4 threads
...
info depth 16 seldepth 32 multipv 1 score cp 42 nodes 1555455 nps 1555455 hashfull 529 tbhits 0 time 1000 pv g3g4 h7g7 b2e2 c9e7 h0i2 h9i7 i0h0 i9h9 h2h6 b9d8 b0c2 g6g5 g4g5 g7g0 h0g0 h9h6 i2g3 e7g5 g3f5 a9b9
它这个nps,好像少了个0?AI说:皮卡鱼基于NNUE,采用蒙特卡洛树搜索(MCTS)与Alpha-Beta剪枝结合的方式,节点评估更依赖深度学习模型的实时预测。其节点生成效率较高。Fritz Chess以传统Alpha-Beta搜索为主,依赖手工优化的评估函数和历史启发式规则,其节点生成量通常更大。
不管咋滴,1秒能出好走法就行。N100整机才500人民币,足以,足矣。
许峰雄是深蓝超级计算机的核心设计者,1985年起在卡内基梅隆大学启动研究,1989年加入IBM后主导“深蓝”项目,最终在1997年以3.5比2.5的比分战胜卡斯帕罗夫,成为人工智能发展史上的里程碑。深蓝采用30台IBM RS6000工作站,配备480个专用象棋芯片,理论搜索速度达每秒10亿棋局,实际最大速度为2亿棋局/秒。
Fritz 9 Chess Benchmarks,基准是Pentium III 1G比(1),AMD Duron 1000 0.96,58630E3/1E8=0.5863亿
据说天天象棋的残局换了个垃圾引擎——舍不得掏钱。天天象棋广告极多,唯一比JJ象棋强的是:不是每个月更新500多MB。JJ象棋小米版不带每日残局(华为版有)。他们这种搞法,我一点买新手机的欲望都没有。
通讯借口请搜 Description of the universal chess interface (UCI) April 2006
浙公网安备 33010602011771号