Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
bf80b8e
fix: 冰火人游戏进行中R键重开无效
Barbatosishere Aug 19, 2026
69b6ddd
fix: 4个游戏HUD提示R重开但按键仅在GAME_OVER生效
Barbatosishere Aug 19, 2026
ce35da6
feat: 围棋AI全面升级——接口化多引擎+神经网络评估器+GPU加速+训练流水线
Barbatosishere Aug 20, 2026
ecc32e5
feat: 中国象棋AI重构——独立接口+内置增强引擎+Pikafish外挂
Barbatosishere Aug 20, 2026
dc84d37
fix: 五子棋AI后台线程防冲突
Barbatosishere Aug 20, 2026
0d6ef64
perf: MCTS节点前向结果缓存+训练8-fold aux复用+heuristicSort数组化
Barbatosishere Aug 20, 2026
5a4fc18
perf: 合并走法评估+共享树+MCTS热路径优化
Barbatosishere Aug 20, 2026
1f7a702
feat: 策略头引导展开顺序+Momentum优化器
Barbatosishere Aug 20, 2026
08fae96
feat: 策略Top-K剪枝+局部战术搜索升级为受限α-β深度搜索
Barbatosishere Aug 20, 2026
065da1c
perf: 探索衰减+学习率预热
Barbatosishere Aug 20, 2026
c4df960
perf: 权重持久化double→float,文件大小减半
Barbatosishere Aug 20, 2026
b751820
perf: GPU Pass 0 前向加速(子块/字块/顶级三层批量前向)
Barbatosishere Aug 20, 2026
895c2e9
fix: NEV2向后兼容加载+NEV3 save/load格式统一
Barbatosishere Aug 20, 2026
7adbf60
perf: GPU 全前向——策略头+价值头也在GPU上计算
Barbatosishere Aug 20, 2026
be5447e
fix: 修复MCTS/Neural/GPU共27个bug(高7中9低11)
Barbatosishere Aug 22, 2026
d2aabd7
fix: 修复扫描发现的剩余GPU问题
Barbatosishere Aug 23, 2026
67ce81d
fix: 修复遗留中低严重性问题
Barbatosishere Aug 23, 2026
926e24c
docs: 修正探索衰减注释为实际 1-based 代次
Barbatosishere Aug 23, 2026
6778c8a
fix: 修复第三轮扫描发现的核心bug(价值视角反转/树重用冻结/GPU坐标转置等)
Barbatosishere Aug 23, 2026
0e0acd6
fix: super-ko全局同型检测+GPU缓冲泄漏+trainBatch越界修复
Barbatosishere Aug 23, 2026
3228fb2
fix: 第四轮扫描修复——早退路径清空currentRoot+根节点plane3+KataGo同步
Barbatosishere Aug 23, 2026
831d863
fix: 补全super-ko过滤到走法生成层
Barbatosishere Aug 24, 2026
83ab550
fix: 第五轮扫描修复——搜索深度/训练梯度/GPU内核
Barbatosishere Aug 24, 2026
3e4d2cb
perf: modelLock 从 synchronized 改为读写锁
Barbatosishere Aug 24, 2026
22db9ae
fix: 第六轮扫描修复——GoMove语义/线程安全/AI后台线程/slider接线
Barbatosishere Aug 24, 2026
bc49e77
perf: FPU(First Play Urgency)优化+GPU可选配置
Barbatosishere Aug 24, 2026
8328dd1
fix: 全面修复小游戏12个bug
Barbatosishere Aug 24, 2026
3acc2ec
fix(render): 象棋/国际象棋 overlay 前补 flush,消除 z-fighting
Barbatosishere Aug 25, 2026
d49d428
fix(render): FruitNinja 贴图坐标改 (x0,y0,x1,y1) + JumpGame 玩家层前 flush
Barbatosishere Aug 25, 2026
5ea9e46
fix(sudoku): 选中高亮提对比度+完成态 timer 冻结
Barbatosishere Aug 25, 2026
b273794
fix(gameplay): 冰火/鼠反应/接水管/扫雷 4 处逻辑修正
Barbatosishere Aug 25, 2026
a2f7bff
feat(maze/sokoban): 迷宫多关卡+鬼AI/推箱子难度递增, fix(whack): 地鼠贴图对齐
Barbatosishere Aug 25, 2026
b5be0b4
fix(go-ai): MCTSGoAI 中盘防 OOM + 价值坍塌保护
Barbatosishere Aug 25, 2026
8642abf
feat(gomoku): 棋盘大小循环补 11/17 档,支持 9-19 六档自定义
Barbatosishere Aug 25, 2026
be2399c
polish(go-ai): groupKey 改形状归一相对坐标,同形棋群去重更准确
Barbatosishere Aug 25, 2026
493bc1a
polish(sokoban): 大关卡逆向打乱步数扩到 1500+boxCount*500,boxCount 同步下调
Barbatosishere Aug 25, 2026
5617009
polish(minesweeper): 三段式兜底,雷数严格等于配置
Barbatosishere Aug 25, 2026
cff205e
fix(fruit-ninja): 炸弹 emoji 改字串 B+红描边,跨字体可见
Barbatosishere Aug 25, 2026
8515278
fix(whack): 删 64x64 资源包假设的 blit,只保留色块+表情
Barbatosishere Aug 25, 2026
bd1fd43
fix(chess): AI 引擎异常不再静默吞,HUD 显示错误条
Barbatosishere Aug 25, 2026
149a97b
fix(gomoku): onRemoteMove 加范围校验防越界 AIOOBE 静默
Barbatosishere Aug 25, 2026
eae475c
fix(puzzle): 完成态 elapsedSeconds 冻结不再每帧重算
Barbatosishere Aug 25, 2026
01a4ef7
fix(color-chase): onRemoteState 坏格 try/catch,onRemoteMove 长度校验
Barbatosishere Aug 25, 2026
02b8b83
fix(icefire): isGameOver 检查前移,弹窗期内也能结算
Barbatosishere Aug 25, 2026
80f0200
fix(tower-defense): 胜利判定去掉不可达条件,补 victory 字段
Barbatosishere Aug 25, 2026
9817d3b
fix(go-ai): 旧 worker 超时后 cancel(true) 加速回收
Barbatosishere Aug 25, 2026
7327c22
fix(go): onClose interrupt AI 线程防泄漏,settings.json 限 1MB+BufferedReader
Barbatosishere Aug 25, 2026
8e71520
fix(landlord): 压牌对手牌较多时避免无谓炸弹,chooseActivePlay 防空手
Barbatosishere Aug 25, 2026
53944e8
fix(landlord): applyState 仅 BID 前覆盖 landlordCards,避免已发牌阶段被空 list 清掉
Barbatosishere Aug 25, 2026
1852b55
polish(icefire): 删 activeInstance dead code,无任何读取方
Barbatosishere Aug 25, 2026
9bf6cb8
fix(tictactoe): onRemoteMove 越界校验+检查 makeMove 返回值
Barbatosishere Aug 25, 2026
c519a6c
fix(icefire): applyReceivedState STATE 报文加字段数+level 范围+钻石格边界防御
Barbatosishere Aug 25, 2026
06f6c10
fix(go): onRemoteMove split 长度+坐标范围校验
Barbatosishere Aug 25, 2026
9f5e295
fix(chess-sim): executor awaitTermination 120s,worker 异常兜底
Barbatosishere Aug 25, 2026
31b658d
fix(color-chase): onRemoteState 字段数+坐标/level/颜色范围校验
Barbatosishere Aug 25, 2026
1c99ddd
fix(go-train): 训练线程池 awaitTermination 5s,防 native 资源半释放
Barbatosishere Aug 25, 2026
2fec807
fix(mouse-tunnel): 死亡后开始/返回按钮上移避免被结算文案挡住
Barbatosishere Aug 25, 2026
e9e5371
fix(color-chase): R 弹窗期关弹窗+gameOver 状态不累积 heldKeys
Barbatosishere Aug 25, 2026
adb04a9
perf(black-hole): 3 个纹理 ResourceLocation 提升 static final,避免每帧反射
Barbatosishere Aug 25, 2026
39b257a
fix(whack): R 重开支持+ESC 改用 GLFW 常量
Barbatosishere Aug 25, 2026
9d4fbf3
polish(dice): ESC 硬编码 256 改 GLFW 常量
Barbatosishere Aug 25, 2026
8f5251e
fix(chess): 引擎无合法走法时设 aiStalled+错误消息,避免 tick 死循环
Barbatosishere Aug 25, 2026
c42851d
fix(go): resetGame 中断旧 AI 线程+清 pending,重开不串走法
Barbatosishere Aug 25, 2026
fd92e7f
fix(icefire): CLIENT HOST 崩溃超时检测+粒子 update 顺序
Barbatosishere Aug 25, 2026
863f6be
fix(landlord): STATE 同步后清空选牌列表,避免旧索引残留
Barbatosishere Aug 25, 2026
293f581
fix(settings): JSON 损坏重试+null key 过滤,导入与 ensureLoaded 统一防御
Barbatosishere Aug 26, 2026
3f61303
fix(color-chase): p2LastSafe/lastColorChangeTime/gameStartTime 字段初始化 …
Barbatosishere Aug 26, 2026
57bd45e
fix(piano-tiles): Note: 行嵌套 split 加长度+try/catch,畸形音符不致整曲崩
Barbatosishere Aug 26, 2026
e086f5b
fix(go-ai): region 集合 split 加长度+try/catch,防御畸形坐标字符串
Barbatosishere Aug 26, 2026
95f4087
fix(go): settingsEngine/katagoPath 非空才 put,避免 null 进 GSON
Barbatosishere Aug 26, 2026
00b76ef
fix(pikafish): shutdown hook 类级共享 LIVE_INSTANCES,避免多次创建累积 hook
Barbatosishere Aug 26, 2026
9776b84
fix(katago): shutdown hook 类级共享 LIVE_INSTANCES,与 PikafishChessAI 一致
Barbatosishere Aug 26, 2026
a798053
fix(whack): init() 开头 clearWidgets 防止缩放重复叠加按钮
Barbatosishere Aug 26, 2026
47919e6
fix(tower-defense): init() 开头 clearWidgets 防止缩放重复叠加 6 个按钮
Barbatosishere Aug 26, 2026
d1f7b7d
fix(dice): init() 开头 clearWidgets 防止缩放重复添加 exit/reset 按钮
Barbatosishere Aug 26, 2026
da71671
fix(memory): init() 开头 clearWidgets 防止缩放重复添加 start/reset 按钮
Barbatosishere Aug 26, 2026
6955a44
fix(color-chase): removed() 清空 heldKeys 防泄漏到其他屏
Barbatosishere Aug 26, 2026
83878fa
fix(klotski): init() 改用 board==null 首入判断,避免缩放重置进度
Barbatosishere Aug 26, 2026
909b7f6
fix(chess): Pikafish 路径为空直接回退内置引擎,不再硬编码 E 盘默认
Barbatosishere Aug 26, 2026
2386f06
fix(katago): 启动前 canExecute 检查,Mac/Linux 缺权限时提示 chmod +x
Barbatosishere Aug 26, 2026
bbe4d01
fix(color-chase): p1Score/p2Score 饱和 999999+level 上限 999,防 3 小时对局 int 溢出
Barbatosishere Aug 26, 2026
a053bf9
fix(fruit-ninja): lives 字符串 repeat 上限 20,防 lives bug 时字符爆炸
Barbatosishere Aug 26, 2026
7e5b2cf
fix(file-io): writeTextFile/writeBytes 改 tmp+atomic move,防写到一半崩溃损坏原文件
Barbatosishere Aug 26, 2026
fea5244
fix(file-dialog): Frame+FileDialog 居中到主屏,防多显示器落屏外阻塞
Barbatosishere Aug 26, 2026
4cc3a3e
fix(piano-tiles): AWT FileDialog 居中+mouseX 四舍五入防 GUI scale 偏 1-3 像素
Barbatosishere Aug 26, 2026
32dfb46
fix(i18n): GameConsoleItem 悬浮提示用 translatable key,en/zh 双语补全
Barbatosishere Aug 26, 2026
24f8230
fix(go): saveSettings 走 ExternalFileManager 原子写,防崩溃截断 game_settings.json
Barbatosishere Aug 26, 2026
a8b775e
fix(meta): mods.toml 加 side=CLIENT,防专用服务端加载 Screen 失败
Barbatosishere Aug 26, 2026
dcfb59f
fix(settings): settings 改 ConcurrentHashMap,SETTINGS_FILE 改 public 供外部引用
Barbatosishere Aug 26, 2026
4dc0f15
fix(mp-lobby): removed() 清空 static pendingInvite,防切世界时邀请混淆
Barbatosishere Aug 26, 2026
02720fd
fix(model): GameConsoleItem 补 display 字段(thirdperson/firstperson/gui/…
Barbatosishere Aug 26, 2026
df4ab7c
chore(resources): 排除空 recipes/ 目录与 .gitignore 进 jar,清理打包冗余
Barbatosishere Aug 27, 2026
582dd65
chore(build): processResources 加 exclude 规则,空目录/占位文件不进 jar
Barbatosishere Aug 27, 2026
ddf95b5
ci: 补 GitHub Actions 构建 workflow(compile+jar+artifact 上传)
Barbatosishere Aug 27, 2026
7f17444
perf(render): 动画点/生命条改预计算帧表,消除每帧 StringBuilder/repeat 分配
Barbatosishere Aug 27, 2026
ecd0301
fix(chess-ai): 搜索超时中断未回滚棋盘,根层/negamax/quiescence 三层 make/unmake 补 try…
Barbatosishere Aug 27, 2026
776d080
test(sim): 新增五子棋AI/象棋自对弈/围棋规则/井字棋/斗地主 五组件无头模拟测试
Barbatosishere Aug 27, 2026
eb9daad
fix(chess-lan): 联机走法校验补全+和棋误判+AI线程退出残留回调
Barbatosishere Aug 27, 2026
4cdfe61
fix(go-adv): KataGo对抗训练子进程异常路径泄漏
Barbatosishere Aug 27, 2026
b9634d7
fix(go-ai): 梯度NaN防护+MCTS Top-K剪枝竞态
Barbatosishere Aug 27, 2026
9658a44
fix(fruit-ninja): 炸弹引线绘制坐标计算错误
Barbatosishere Aug 27, 2026
2a8ab30
fix(pause-state): ESC弹窗期间计时/蓄力状态未随暂停偏移,横扫8款游戏
Barbatosishere Aug 27, 2026
baa2d9f
fix(sokoban): 跳关/重置不重新init()导致画面错位
Barbatosishere Aug 27, 2026
ba8f16c
fix(piano-tiles): 文件导入异常路径 Frame 未 dispose
Barbatosishere Aug 27, 2026
0cf8b04
chore(build): 产物版本号 beta3 → beta4
Barbatosishere Aug 27, 2026
25bdc2b
fix(build): neoforge.mods.toml 含两个 [[mods]] 块致 FML 判 duplicate mod 拒载
Barbatosishere Aug 28, 2026
2842ecb
chore(build): 产物后缀回退 beta4 -> beta3,与游戏机安装版本号对齐
Barbatosishere Aug 28, 2026
fec7111
fix: 第九轮扫描修复——斗地主multiset扣牌/Go读锁/OpenCL释放链/象棋AI代际失效/双屏代际守卫/AI平值压牌
Barbatosishere Aug 28, 2026
3aecaef
test: 斗地主完整对局+围棋劫争 super-ko 无头模拟
Barbatosishere Aug 28, 2026
4803eb9
fix(build): 删 JogAmp 死仓库 + JNA jarJar 打包 + item display 键拆分 + mods.to…
Barbatosishere Aug 28, 2026
d5d514f
fix(chess): 象棋引擎 PVS 零窗口/aspiration 死循环/路径重复/全宽 TT 归一 8 处修复
Barbatosishere Aug 28, 2026
3b843e3
fix(ai): 五子棋 TT 边界分类/越界 2 处理 + 井字双角叉防御 + 围棋贴目 7.5+锁
Barbatosishere Aug 28, 2026
dd86a9d
fix(go-ai): KataGo 双消费重构 + MCTS 标准选着/PUCT/早停门槛/树纯 prior + OpenCL 死代码删…
Barbatosishere Aug 28, 2026
68c92a3
fix(landlord): 四带二牌型/翻倍倍数/AI 身份上下文/TreeMap 排序/飞机翅放宽/LAN 预校验+REJECT+溢出钳制
Barbatosishere Aug 28, 2026
c67aee1
fix(network): LEAVE 校验/DECLINE 斗地主路径/服务端断线广播/反射缓存+日志/限流+等待超时
Barbatosishere Aug 28, 2026
2cd876e
fix(boards): 象棋 AI 局代号守卫 + 国际象棋 50 回合/三次重复/LAN 再来一局 + 五子棋尺寸同步 + 围棋 RE…
Barbatosishere Aug 28, 2026
3d4f0b7
fix(screens): 13 个游戏屏 + GameSelector/工具类共 17 项修复
Barbatosishere Aug 28, 2026
5b98cc7
chore: 忽略本地 .zcode 工作目录
Barbatosishere Aug 28, 2026
1fd55c0
fix(build): JNA 从 jarJar 改为 compileOnly,消除 Java 22 模块冲突
Aug 28, 2026
18d4077
fix(go-ai): 第九轮 — 训练标签/贴目/stderr/worker 中断/AI 回合守卫/expand 竞态/syncBoar…
Aug 29, 2026
1816a43
fix(chess): 第九轮 — 五子棋多尺寸/PST 转置/AI 线程代数/Pikafish 常驻读线程/LAN 校验/三次重复/易位权贯穿
Aug 29, 2026
d3b0eb9
fix(screens): 第九轮 — 重开/状态机/失焦清键/粒子 tick 化/ESC/emoji 12 项
Aug 29, 2026
1795714
fix(network/lobby/tools): 第九轮 — 协议版本/邀请取消兜底/断线通知/列表分页/文件对话框后台化/斗地主选牌/…
Aug 29, 2026
cc299a6
build: beta6 — 第九轮 36 项 bug 修复汇总(围棋训练/棋类引擎/重开状态机/联机协议/大厅工具)
Aug 29, 2026
660f29e
fix: 修复第十轮 P0/P1 生命周期、联机与规则问题
Aug 29, 2026
a617baa
build: beta7
Aug 29, 2026
3ca0bde
fix: 修复联机回合、围棋设置与文件降级问题
Barbatosishere Aug 30, 2026
33fdeb7
feat: 围棋MCTS性能优化+并发保存修复+全项目无头压测回归
Barbatosishere Sep 10, 2026
e886676
style: 移除测试方法签名尾随空格,修复CI whitespace检查
Barbatosishere Sep 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build & Verify

on:
push:
branches: [ main, gpu-accel ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'

- name: Setup Gradle cache
uses: gradle/actions/setup-gradle@v4

- name: Check whitespace
run: |
if git rev-parse HEAD^ >/dev/null 2>&1; then
git diff --check HEAD^..HEAD
else
git show --check --oneline HEAD
fi

- name: Compile and test
run: bash ./gradlew compileJava test --no-daemon --stacktrace

- name: Package jar
run: bash ./gradlew jar --no-daemon

- name: Verify jar contents
shell: bash
run: |
test -n "$(find build/libs -maxdepth 1 -type f -name '*.jar' -print -quit)"
! jar tf build/libs/*.jar | grep -E '(^|/)(jna|jna-platform)-[^/]+\.jar$|^com/sun/jna/'

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: GameConsole-jar
path: build/libs/*.jar
retention-days: 14
48 changes: 9 additions & 39 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,10 @@
# MacOS DS_Store files
.DS_Store

# Gradle cache folder
.gradle

# Gradle build folder
build

# IntelliJ
out/
.idea
*.iml
# mpeltonen/sbt-idea plugin
.idea_modules/

# VS Code
/.zcode/
.gradle/
.idea/
.vscode/

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Common working directory
run

# Decompiled sources
decompiled/

# Build logs
build_*.txt

# Tools
cfr.jar
*.ps1

# Root data folder (duplicate)
/data/

# 但保留 src/main/resources 下的真实资源(如合成配方),避免被上述规则误忽略
!src/main/resources/data/
build/
run/
logs/
data/
cuda/
/.bench/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
## 🚀 使用方法

1. 确保已安装 [NeoForge](https://neoforged.net/) 1.21.1
2. 将 `game_console-1.0.0.jar` 放入 `.minecraft/mods` 文件夹
2. 将 `Game Console-1.0.0-NeoForge-1.21.1-beta5.jar` 放入 `.minecraft/mods` 文件夹
3. 启动游戏,在创造模式物品栏「游戏机」分类中获取游戏机
4. 右键使用游戏机即可打开游戏选择界面

Expand All @@ -95,7 +95,7 @@ cd game_console
# 构建
./gradlew build

# 产物位于 build/libs/game_console-1.0.0.jar
# 产物位于 build/libs/Game Console-1.0.0-NeoForge-1.21.1-beta5.jar
```

## 📄 许可证
Expand Down
52 changes: 49 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ group = mod_group_id

repositories {
mavenLocal()
mavenCentral() // 供测试依赖(如 JUnit)下载
mavenCentral() // 供测试依赖(如 JUnit)与 JNA 下载
// 注:JogAmp 仓库已移除——项目从未使用 JOCL 绑定(OpenCL 走 JNA 直调,见 OpenCLBackend)
}

base {
archivesName = mod_id
}

// 构建产物命名:Game Console-<version>-<Loader>-<MC版本>-beta2.jar
// 构建产物命名:Game Console-<version>-<Loader>-<MC版本>-beta6.jar
var loaderName = "NeoForge"
tasks.named('jar') {
archiveBaseName = "${mod_name}-${mod_version}-${loaderName}-${minecraft_version}-beta2"
archiveBaseName = "${mod_name}-${mod_version}-${loaderName}-${minecraft_version}-beta6"
archiveVersion = ''
archiveClassifier = ''
}
Expand All @@ -36,6 +37,8 @@ tasks.withType(Javadoc).configureEach {
}
tasks.withType(ProcessResources).configureEach {
filteringCharset = 'UTF-8'
// ★ 优化:排除任何残留的空目录(如 data/game_console/recipes/)和占位文件
exclude '**/recipes/**', '**/.gitignore', '**/.gitkeep'
}

neoForge {
Expand Down Expand Up @@ -135,12 +138,55 @@ dependencies {
// ─── 单元测试:JUnit 5 ───
testImplementation platform('org.junit:junit-bom:5.10.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.slf4j:slf4j-api:2.0.9'

// ─── OpenCL GPU 加速 ───
// JNA 通过 compileOnly 引入(编译期可见),运行时由玩家环境的 classloader 解析
// —— 不再 jarJar 嵌入。原因:Java 22 模块系统下,自嵌入的 jna jar 会形成
// "com.sun.jna" 自动模块,与其他 mod(如 Iris/Sodium 或 NeoForge 间接带)
// 提供的 jna 形成两个同名模块冲突,触发 ResolutionException。
// 缺 JNA 时由 OpenCLBackend.canExecute() 检测并 catch(Throwable) 回退到 CPU。
compileOnly 'net.java.dev.jna:jna:5.14.0'
}

test {
useJUnitPlatform()
}

// Pure-Java self-play training entry point. Pass arguments with -PtrainArgs="--weights path ...".
tasks.register('trainGoAI', JavaExec) {
group = 'training'
description = 'Train the Go MCTS neural evaluator with self-play'
mainClass = 'com.wzz.game_console.client.screens.games.gogame.GoTrainingMain'
args((project.findProperty('trainArgs') ?: '').toString().trim().split("\\s+").findAll { !it.isEmpty() })
classpath = sourceSets.main.runtimeClasspath
maxHeapSize = '4g'
}

tasks.register('runChessSim', JavaExec) {
group = 'training'
description = '自对弈模拟:内置中国象棋引擎自我对弈,统计胜率/步数/耗时'
mainClass = 'com.wzz.game_console.client.screens.games.chess.ChessSimulationMain'
args((project.findProperty('chessSimArgs') ?: '').toString().trim().split("\\s+").findAll { !it.isEmpty() })
classpath = sourceSets.main.runtimeClasspath
}

tasks.register('adversarialTrain', JavaExec) {
group = 'training'
description = '对抗训练:己方 MCTS AI vs 外部 KataGo 引擎'
mainClass = 'com.wzz.game_console.client.screens.games.gogame.GoAdversarialMain'
args((project.findProperty('advArgs') ?: '').toString().trim().split("\\s+").findAll { !it.isEmpty() })
classpath = sourceSets.main.runtimeClasspath
maxHeapSize = '4g'
}

tasks.register('gpuProbe', JavaExec) {
group = 'training'
description = '探测 OpenCL GPU 设备是否可用'
mainClass = 'com.wzz.game_console.client.screens.games.gogame.GoGpuProbe'
classpath = sourceSets.main.runtimeClasspath
}

// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/wzz/game_console/ModMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import com.wzz.game_console.init.ModItems;
import com.wzz.game_console.init.ModNetworks;
import com.wzz.game_console.init.ModTabs;
import com.wzz.game_console.network.ServerDisconnectWatcher;
import com.wzz.game_console.util.ExternalFileManager;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.neoforge.common.NeoForge;

@Mod(ModMain.MODID)
public class ModMain {
Expand All @@ -19,6 +21,8 @@ public ModMain(IEventBus modEventBus, ModContainer modContainer) {
modEventBus.addListener(ModNetworks::register);
ModItems.REGISTRY.register(modEventBus);
ModTabs.REGISTRY.register(modEventBus);
// 服务端断线看门狗:玩家退出服务器时广播 PLAYER_QUIT(客户端据此关闭死等的对局界面)
NeoForge.EVENT_BUS.addListener(ServerDisconnectWatcher::onPlayerLoggedOut);
}

private void commonSetup(final FMLCommonSetupEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,30 +266,56 @@ private int getCategoryColor(String category) {

/** 打开文件对话框导入外部游戏设置 JSON */
private void importSettingsFromFile() {
try {
Frame frame = new Frame();
frame.setAlwaysOnTop(true);
FileDialog dialog = new FileDialog(frame, "选择游戏设置文件 (.json)", FileDialog.LOAD);
dialog.setFile("*.json");
dialog.setVisible(true);
String filePath = dialog.getFile();
String dirPath = dialog.getDirectory();
frame.dispose();

if (filePath == null || dirPath == null) return;

File srcFile = new File(dirPath, filePath);
if (!srcFile.exists() || !srcFile.getName().endsWith(".json")) return;

Path srcPath = srcFile.toPath();
boolean success = GameSettings.importFromFile(srcPath);

importMessage = success ? "设置导入成功!" : "导入失败:文件格式不正确";
importMessageTime = System.currentTimeMillis();
} catch (Exception e) {
importMessage = "导入失败:" + e.getMessage();
importMessageTime = System.currentTimeMillis();
}
// ★ Bug修复:FileDialog.setVisible(true) 是模态阻塞调用,在 MC 主线程直接打开
// 会冻结整个游戏(停帧、无响应)。改为在后台 daemon 线程弹窗,
// 用户选完后 mc.execute 回主线程执行实际导入与提示(importMessage 由 render 读取)
Thread picker = new Thread(() -> {
Frame frame = null;
try {
frame = new Frame();
frame.setAlwaysOnTop(true);
// ★ Bug修复:原版不设位置,Windows 多显示器/扩展屏(主屏 x<0 或 y<0)
// 时 FileDialog 会落在不可见区域,玩家看不见但模态阻塞,只能 Alt+F4。
// setLocationRelativeTo(null) 强制居中到主屏可视区
frame.setLocationRelativeTo(null);
FileDialog dialog = new FileDialog(frame, "选择游戏设置文件 (.json)", FileDialog.LOAD);
dialog.setFile("*.json");
dialog.setLocationRelativeTo(frame);
dialog.setVisible(true); // 只阻塞本后台线程,不再冻结游戏
String filePath = dialog.getFile();
String dirPath = dialog.getDirectory();

if (filePath == null || dirPath == null) return; // 用户取消

File srcFile = new File(dirPath, filePath);
if (!srcFile.isFile() || !srcFile.getName().toLowerCase(java.util.Locale.ROOT).endsWith(".json")) {
Minecraft.getInstance().execute(() -> {
importMessage = "导入失败:请选择 JSON 文件";
importMessageTime = System.currentTimeMillis();
});
return;
}

Path srcPath = srcFile.toPath();
// 回到 MC 主线程执行导入与界面提示
Minecraft.getInstance().execute(() -> {
boolean success = GameSettings.importFromFile(srcPath);
importMessage = success ? "设置导入成功!" : "导入失败:文件格式不正确";
importMessageTime = System.currentTimeMillis();
});
} catch (Exception e) {
String msg = "导入失败:" + e.getMessage();
Minecraft.getInstance().execute(() -> {
importMessage = msg;
importMessageTime = System.currentTimeMillis();
});
} finally {
// ★ 修复 AWT Frame 泄漏:dispose 移入 finally,异常/用户取消路径也会释放
if (frame != null) frame.dispose();
}
}, "GameConsole-SettingsImport");
picker.setDaemon(true);
picker.start();
}

@Override
Expand Down
Loading
Loading