mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-06-28 16:35:55 +08:00
96a94aaddf
- 构建系统:Makefile 迁移至 CMakeLists.txt,支持 cJSON 和 WinHTTP - 项目结构:src/ 按功能拆分为 core/、gui/、network/、record/、llm/ 子目录 - 新功能:集成大模型 AI(WinHTTP + cJSON,兼容 OpenAI 协议),支持异步请求 - 渲染修复:IupDraw* 替换为 Windows GDI,修复画布黑屏问题 - 网络修复:ENet 初始化幂等化,实现真实 get_local_ip() (Winsock) - 代码质量:删除死代码 (dfs/count_threats_in_direction),修复头文件守卫, sprintf→snprintf 防溢出,strncpy 安全终止,GDI 资源泄漏修复 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
52 lines
2.2 KiB
C
52 lines
2.2 KiB
C
/**
|
|
* @file globals.h
|
|
* @brief 全局变量声明头文件
|
|
* @note 集中管理所有全局变量的声明,提高代码可维护性
|
|
*/
|
|
|
|
#ifndef GLOBALS_H
|
|
#define GLOBALS_H
|
|
|
|
#include "type.h"
|
|
#include "gobang.h"
|
|
#include <stdbool.h>
|
|
|
|
// ==================== 游戏核心变量 ====================
|
|
extern int BOARD_SIZE; // 当前实际使用的棋盘尺寸
|
|
extern int board[MAX_BOARD_SIZE][MAX_BOARD_SIZE]; // 棋盘状态存储数组
|
|
extern Step steps[MAX_STEPS]; // 存储所有落子步骤的数组
|
|
extern const int direction[4][2]; // 四个方向:向下、向右、右下、左下
|
|
extern int step_count; // 当前步数计数器
|
|
|
|
// ==================== 游戏配置变量 ====================
|
|
extern bool use_forbidden_moves; // 是否启用禁手规则的标志
|
|
extern int use_timer; // 是否启用计时器的标志
|
|
extern int time_limit; // 每回合的时间限制(秒,内部存储)
|
|
extern int network_port; // 网络端口
|
|
extern int network_timeout; // 网络超时时间
|
|
|
|
// ==================== AI相关变量 ====================
|
|
extern double defense_coefficient; // 防守系数
|
|
extern int ai_difficulty; // AI难度 (1-5)
|
|
|
|
// ==================== LLM大模型相关变量 ====================
|
|
extern int llm_use; // 是否使用LLM (0=算法AI, 1=大模型)
|
|
extern char llm_endpoint[MAX_LLM_ENDPOINT_LEN]; // API地址
|
|
extern char llm_api_key[MAX_LLM_API_KEY_LEN]; // API Key
|
|
extern char llm_model[MAX_LLM_MODEL_LEN]; // 模型名
|
|
|
|
// ==================== 网络相关变量 ====================
|
|
extern NetworkGameState network_state; // 网络游戏状态
|
|
|
|
// ==================== GUI相关变量 ====================
|
|
extern int current_player_gui; // GUI当前玩家
|
|
extern int game_over; // 游戏结束标志
|
|
extern char status_message[256]; // 状态消息
|
|
|
|
// ==================== 记录相关变量 ====================
|
|
extern int player1_final_score; // 玩家1最终得分
|
|
extern int player2_final_score; // 玩家2最终得分
|
|
extern int scores_calculated; // 评分计算标志
|
|
extern char winner_info[50]; // 存储胜负信息
|
|
|
|
#endif // GLOBALS_H
|