deeper-cli 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,62 @@
1
+ # Chinese Chess AI - 中国象棋智能体
2
+
3
+ 基于 Alpha-Beta 搜索 + 自博弈学习的轻量级中国象棋 AI 引擎
4
+
5
+ ## 特性
6
+ - ✅ 完整的中国象棋规则实现
7
+ - ✅ Alpha-Beta 剪枝搜索算法
8
+ - ✅ 高级优化:置换表、迭代加深、历史启发、杀手步法
9
+ - ✅ 自博弈强化学习系统(CPU友好)
10
+ - ✅ 轻量级设计,无需GPU
11
+ - ✅ 智能评估函数(棋子价值+位置价值+机动性)
12
+ - ✅ 命令行交互界面
13
+
14
+ ## 安装依赖
15
+ ```bash
16
+ pip install -r requirements.txt
17
+ ```
18
+
19
+ ## 使用方法
20
+
21
+ ### 人机对战
22
+ ```bash
23
+ python main.py --mode vs
24
+ ```
25
+
26
+ ### AI自训练
27
+ ```bash
28
+ python main.py --mode train --epochs 100
29
+ ```
30
+
31
+ ### AI对弈(观看两AI对战)
32
+ ```bash
33
+ python main.py --mode watch
34
+ ```
35
+
36
+ ## 项目结构
37
+ ```
38
+ chinese_chess_ai/
39
+ ├── core/ # 核心引擎
40
+ │ ├── board.py # 棋盘状态管理
41
+ │ ├── pieces.py # 棋子定义与规则
42
+ │ ├── move_generator.py # 走法生成器
43
+ │ └── evaluator.py # 局面评估器
44
+ ├── search/ # 搜索算法
45
+ │ ├── alphabeta.py # Alpha-Beta搜索
46
+ │ └── optimizations.py # 搜索优化技术
47
+ ├── learning/ # 学习系统
48
+ │ ├── trainer.py # 自博弈训练器
49
+ │ └── experience.py # 经验回放缓冲区
50
+ ├── ui/ # 用户界面
51
+ │ └── cli.py # 命令行界面
52
+ ├── utils/ # 工具函数
53
+ │ └── helpers.py # 辅助函数
54
+ ├── main.py # 主入口
55
+ └── config.py # 配置参数
56
+ ```
57
+
58
+ ## 技术栈
59
+ - Python 3.8+
60
+ - 纯NumPy计算(无深度学习框架依赖)
61
+ - 经典游戏树搜索算法
62
+ - 轻量级强化学习
@@ -0,0 +1,63 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ 中国象棋AI - 配置参数
4
+ """
5
+
6
+ # 搜索配置
7
+ SEARCH_CONFIG = {
8
+ 'max_depth': 4, # 最大搜索深度(默认4层,平衡速度与智能)
9
+ 'iterative_deepening': True, # 启用迭代加深
10
+ 'use_transposition_table': True, # 使用置换表
11
+ 'use_killer_moves': True, # 使用杀手步法
12
+ 'use_history_heuristic': True, # 使用历史启发
13
+ 'null_move_pruning': True, # 空步裁剪
14
+ 'null_move_reduction': 2, # 空步减少深度
15
+ 'aspiration_window': 50, # 渴望窗口大小
16
+ 'time_limit': 3.0, # 时间限制(秒)
17
+ }
18
+
19
+ # 评估函数配置
20
+ EVALUATOR_CONFIG = {
21
+ # 棋子基础价值(分)
22
+ 'piece_values': {
23
+ 'KING': 10000, # 将/帅
24
+ 'ADVISOR': 200, # 士/仕
25
+ 'ELEPHANT': 200, # 象/相
26
+ 'HORSE': 400, # 马
27
+ 'CHARIOT': 900, # 车
28
+ 'CANNON': 450, # 炮
29
+ 'PAWN': 100, # 兵/卒
30
+ },
31
+
32
+ # 位置价值表权重
33
+ 'position_weight': 0.6,
34
+
35
+ # 机动性权重
36
+ 'mobility_weight': 0.15,
37
+
38
+ # 保护与威胁权重
39
+ 'protection_weight': 0.1,
40
+
41
+ # 中心控制权重
42
+ 'center_control_weight': 0.15,
43
+ }
44
+
45
+ # 训练配置
46
+ TRAINING_CONFIG = {
47
+ 'learning_rate': 0.01,
48
+ 'epochs': 100,
49
+ 'games_per_epoch': 10,
50
+ 'experience_replay_size': 10000,
51
+ 'batch_size': 32,
52
+ 'exploration_rate': 0.3, # 初始探索率
53
+ 'exploration_decay': 0.995, # 探索率衰减
54
+ 'min_exploration_rate': 0.05, # 最小探索率
55
+ 'discount_factor': 0.95, # 折扣因子
56
+ }
57
+
58
+ # 棋盘配置
59
+ BOARD_CONFIG = {
60
+ 'rows': 10,
61
+ 'cols': 9,
62
+ 'red_side': 'bottom', # 红方在下方
63
+ }
@@ -0,0 +1 @@
1
+ numpy>=1.21.0
package/dist/cli/index.js CHANGED
@@ -3843,6 +3843,11 @@ var init_DeepSeekClient = __esm({
3843
3843
  const rc = m.reasoning_content || m.thinking;
3844
3844
  if (rc) msg.reasoning_content = rc;
3845
3845
  return msg;
3846
+ }).map((msg) => {
3847
+ if (msg.role === "tool" && !msg.name) {
3848
+ msg.name = "tool";
3849
+ }
3850
+ return msg;
3846
3851
  }),
3847
3852
  temperature: config.temperature,
3848
3853
  max_tokens: config.maxTokens,
@@ -12206,7 +12211,7 @@ async function runLoop(opts, history, tools, toolDefs, confirm) {
12206
12211
  ttc++;
12207
12212
  GS.tc++;
12208
12213
  } else {
12209
- history.push({ role: "tool", content: `Error: ${String(r2.reason)}`, tool_call_id: "parallel" });
12214
+ history.push({ role: "tool", content: `Error: ${String(r2.reason)}`, tool_call_id: "parallel", name: "parallel" });
12210
12215
  }
12211
12216
  }
12212
12217
  } else if (safe.length === 1) {
@@ -12450,7 +12455,10 @@ ${globalRules}` });
12450
12455
  }
12451
12456
  r2.push(e);
12452
12457
  }
12453
- return r2;
12458
+ return r2.map((m) => {
12459
+ if (m.role === "tool" && !m.name) m.name = "tool";
12460
+ return m;
12461
+ });
12454
12462
  }
12455
12463
  function trimHistory(h, max) {
12456
12464
  while (h.length > max) h.shift();