(毕业论文)基于QT的中国象棋算法设计与实现.doc
文本预览下载声明
基于QT的中国象棋算法设计与实现
摘 要
中国象棋发展至今已有数千年的历史了,它是中华民族智慧的结晶。在我国,中国象棋的普及程度是其它棋类无法比拟的,大至国际、国内比赛,小至社区街道。
本文章在研究分析对局树的基础上,先后运用极大极小查找和α-β修剪对查找下一步的算法进行了改进,并对中国象棋的对弈过程进行了有益的探讨。
最后在此基础上,运用面向对象的技术,综合结构化程序设计方法,将所有的操作逻辑封装于类,实现基于对局树算法的中国象棋游戏系统。With the implementation of Chinese chess algorithm design based on QT
Abstract
Chinese chess development has been several thousand years of history, and it is the wisdom of the Chinese nation. In China, the popularity of Chinese chess board is unmatched by other large to international and domestic competitions, small community streets。
This article is based on research and analysis on the game tree, has to find and use Minimax α-β pruning algorithm for finding the next improvement, the process of Chinese chess and chess for a useful discussion.
Finally, on this basis, the use of object-oriented technology, integrated structured programming method, all of the operating logic encapsulated in a class-based system to achieve Chinese chess game game tree algorithm. The system uses QT development tools to achieve human-computer chess and Chinese chess program that has a double battle of chess.
Key words: Chinese chess; artificial intelligence;game tree;Alpha-Beta search目 录
摘 要 i
Abstract ii
1 绪论 1
1.1 中国象棋游戏设计背景和研究意义 1
1.2 国内外象棋软件发展概况 1
1.3 中国象棋游戏设计研究方法 1
1.4 本文的主要工作 2
2 系统的分析和设计 3
2.1 棋盘和棋子的表示 3
2.2 着法生成 5
3 博弈程序的实现 7
3.1 搜索算法 7
3.2 估值函数(Evaluation Function) 11
3.2.1 估值函数简介 11
3.2.2 估值函数的优化 12
3.2.3 着法排序 13
3.3 局面评估 16
4 走棋程序的实现 20
4.1 悔棋和还原功能的实现 20
4.2 着法名称显示功能的实现 22
4.3 主要函数 26
4.4 将军检测 30
5 系统实现 31
5.1 系统的整体规划 31
5.2 对弈功能的实现 32
总 结 38
参考文献 39
致 谢 40
外文原文 41
中文翻译 48
1 绪论
1.1 中国象棋游戏设计背景和研究意义国内外象棋软件发展概况
中国象棋游戏设计研究方法本文的主要工作棋盘和棋子的表示
从棋子的角度考虑,如果把棋盘看成是一个平面坐标系,可以知道每一个棋子的位置信息:小于10的横坐标和小于11的纵坐标;又在棋盘上最多32个棋子,故可以用一个32个字节的一维数组表示所有32个棋子的位置,其中每个字节的高4位表示该棋子的横坐标,低4位表示棋子的纵坐标。而己被吃掉的棋子用坐标范围以外的数表示。这样棋盘信息就被装入这32个字节中。当然也可以把棋盘看作一维的,每个元素保存直接的位置信息。
两种棋盘表示方法:一是做一个棋盘数组;二是做一个棋子数组。棋盘数组中由棋子的位置获得棋子的类型可以在常数时间内完成,但由棋子的类型获得棋子的位置需要遍历;在棋子数组中由棋子的类型获得棋子的位置可
显示全部