mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-05-10 02:19:46 +08:00
重构输入处理:统一使用get_integer_input函数替换scanf
This commit is contained in:
@@ -23,9 +23,9 @@
|
||||
* @brief 记录一步棋的详细信息
|
||||
*/
|
||||
typedef struct {
|
||||
int player; // 执行该步的玩家标识
|
||||
int x; // 落子的行坐标 (0-based)
|
||||
int y; // 落子的列坐标 (0-based)
|
||||
int player; // 执行该步的玩家标识
|
||||
int x; // 落子的行坐标 (0-based)
|
||||
int y; // 落子的列坐标 (0-based)
|
||||
} Step;
|
||||
|
||||
/**
|
||||
@@ -33,9 +33,9 @@ typedef struct {
|
||||
* @details 用于评估棋形,例如判断活三、冲四等关键形态
|
||||
*/
|
||||
typedef struct {
|
||||
int continuous_chess; // 连续同色棋子的数量
|
||||
bool check_start; // 棋子序列的起始端是否为空位(即是否开放)
|
||||
bool check_end; // 棋子序列的末尾端是否为空位(即是否开放)
|
||||
int continuous_chess; // 连续同色棋子的数量
|
||||
bool check_start; // 棋子序列的起始端是否为空位(即是否开放)
|
||||
bool check_end; // 棋子序列的末尾端是否为空位(即是否开放)
|
||||
} DirInfo;
|
||||
|
||||
// ==================== AI相关数据结构 ====================
|
||||
@@ -45,8 +45,8 @@ typedef struct {
|
||||
* @details 用于AI移动排序,存储候选移动及其评估分数
|
||||
*/
|
||||
typedef struct {
|
||||
int x, y; // 位置坐标
|
||||
int score; // 评估分数
|
||||
int x, y; // 位置坐标
|
||||
int score; // 评估分数
|
||||
} ScoredMove;
|
||||
|
||||
/**
|
||||
@@ -54,12 +54,12 @@ typedef struct {
|
||||
* @details 用于AI威胁检测系统
|
||||
*/
|
||||
typedef enum {
|
||||
THREAT_NONE = 0, // 无威胁
|
||||
THREAT_WIN = 5, // 直接获胜
|
||||
THREAT_FOUR = 4, // 活四/冲四
|
||||
THREAT_THREE = 3, // 活三
|
||||
THREAT_DOUBLE = 2, // 双威胁
|
||||
THREAT_POTENTIAL = 1 // 潜在威胁
|
||||
THREAT_NONE = 0, // 无威胁
|
||||
THREAT_WIN = 5, // 直接获胜
|
||||
THREAT_FOUR = 4, // 活四/冲四
|
||||
THREAT_THREE = 3, // 活三
|
||||
THREAT_DOUBLE = 2, // 双威胁
|
||||
THREAT_POTENTIAL = 1 // 潜在威胁
|
||||
} ThreatLevel;
|
||||
|
||||
// ==================== 网络相关数据结构 ====================
|
||||
@@ -69,11 +69,11 @@ typedef enum {
|
||||
* @details 用于网络对战中的消息传输
|
||||
*/
|
||||
typedef struct {
|
||||
int type; // 消息类型
|
||||
int player_id; // 玩家ID
|
||||
int x, y; // 坐标(用于落子)
|
||||
char message[256]; // 消息内容(用于聊天等)
|
||||
time_t timestamp; // 时间戳
|
||||
int type; // 消息类型
|
||||
int player_id; // 玩家ID
|
||||
int x, y; // 坐标(用于落子)
|
||||
char message[256]; // 消息内容(用于聊天等)
|
||||
time_t timestamp; // 时间戳
|
||||
} NetworkMessage;
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ typedef struct {
|
||||
int local_player_id; // 本地玩家ID
|
||||
int remote_player_id; // 远程玩家ID
|
||||
char remote_ip[16]; // 远程IP地址(MAX_IP_LENGTH = 16)
|
||||
int port; // 端口号
|
||||
int port; // 端口号
|
||||
} NetworkGameState;
|
||||
|
||||
#endif // TYPE_H
|
||||
Reference in New Issue
Block a user