1、 本科毕业论文(设计) 五子棋 学院、系 计算机学院 专业名称 计算机科学与技术 年 级 学生姓名 指导教师 abstract As a puzzle game, gobang can develop the thinking ability and intelligence of players, which is interesting and absorbing。 The version of this software,includes two kinds of patterns, standalone mode and network mode。 The former uses a
2、game-tree search algorithm , which can only predict a follow-up move after calculation。 Moreover, the network mode needs to be brought online, in other words, first need a player in a computer start game as the server-side, then the other enter the servers ip to connect and join game in another comp
3、uter as the client. Both modes support undo functions, and the network mode has draw and giving-up function。 While network gaming one player send the coordinate message of pieces received by another, which calls functions to deal with message。 Beyond that, the game has also background music and chat
4、 function。 1 五子棋 摘要 五子棋是一种益智游戏,它能增强玩家的思维能力,提高智力,而且趣 味横生,引人入胜。该版本的五子棋设置了两类模式,单机模式和网络模式。游戏中根 据网络连接标志来判断当前是网络对战还是人机对战。人机对战模式使用的是简单的博 弈树搜索算法,即只向前搜索一步,仅能预测到下一步会发生什么情况。网络对战模式 中一方先建立游戏,作为游戏的服务器端,对方输入服务器 IP 后加入游戏,作为客户 端。两种模式都有悔棋功能,网络对战还有认输、和棋请求的功能。发送五子棋消息主 要发送落子坐标,对方接受到消息后会调用相应的函数处理接收的消息。该游戏还设置 了声音背景,当玩家落子时
5、会有落子的声音,当玩家胜了或输了都会有背景声音。另外 该游戏还设置了聊天功能,战绩统计等基本游戏功能,以方便对弈双方聊天和查看战绩 记录。 关键词 人机对战,网络对战,算法,消息 2 目录目录 第一章 绪论 3 1.1 五子棋介绍 3 1.2 开发背景 . 4 1.3 开发环境及运行环境 5 1.3.1 开发环境 5 1.3.2 运行环境 5 第二章 逻辑架构与设计 6 2.1 棋盘类. 7 2.1.1 棋盘类主要成员变量说明 . 7 2.1.2 棋盘类主要成员函数说明 . 8 2.2 游戏模式类 9 2.2.1 游戏模式类主要成员变量说明 10 2.2.2 游戏模式类主要成员函数说明 10
6、第三章 消息机制. 13 3.1 消息机制的架构 13 3.2 各种消息说明 . 13 3.2.1 落子消息MSG_PUTSTEP . 13 3.2.2 悔棋消息MSG_BACK 13 3.2.3 同意悔棋消息MSG_AGREEBACK 14 3.2.4 拒绝悔棋消息MSG_REFUSEBACK 14 3.2.5 和棋消息MSG_DRAW 14 3.2.6 同意和棋消息MSG_AGREEDRAW . 14 3.2.7 拒绝和棋消息MSG_REFUSEDRAW 14 3.2.8 认输消息MSG_GIVEUP . 15 3.2.9 聊天消息MSG_CHA T . 15 3.2.10 对方信息消息MSG_INFORMA TION . 15 第四章 人机对战主要算法 16 4.1 落子时是否构成五子连珠的算法 16 4.1.1 判断水平方向是否构成五子连珠 . 16 4.1.2 判断竖直方向是否构成五子连珠 17 4.1.3 判断左下方向是否构成五子连珠