基于α-β剪枝算法的智能五子棋

本文介绍了作者基于α-β剪枝算法开发的智能五子棋项目,包括游戏界面、棋型判断、落子估值方式、棋局估值函数和搜索算法的详细过程。通过限制搜索范围、优化估值策略等手段提高算法效率,讨论了进一步的优化思路,如多线程并行计算和引入神经网络。

人工智能的期末大作业,最近几个项目都在单干。还是要养成整理的好习惯!

开原地址:https://github.com/cstackess/Gobang

 

基于α-β剪枝算法的智能五子棋

 

一、基本介绍

 

游戏界面:使用了Java Swing进行开发,如图所示。

 

 

游戏步骤:

1. 先设置游戏的参数,可以选择模式(双人、单人、双机),智能(估值函数、估值函数+搜索树),搜索树(层数、每层节点),再开始游戏;

2. 在棋盘上单击鼠标左键,落下棋子;

3. 在棋盘上单击鼠标右键,查看该点的估值;

4. 可以显示落子顺序和悔棋;

5. 使用搜索树AI时,控制台显示搜索过程;

6. 某方胜利后,游戏结束。

 

 

二、棋型确定

 

问题:

1.五子棋棋型的定义十分模糊,如网上对活二、眠三、死四的定义经常自相矛盾。

2.在大部分论文中,考虑的棋型非常少,如对活三的典型棋型列举不够完整,且常把眠三当死三。

 

正确、完全的棋型

以上问题,令我奔溃了很久,最后对比了N个文献,才确定了比较可信的参考,棋型整理如下:

棋型

定义

表达式

(1黑,2白,0空)

图例(来自五子棋贴吧

长连

至少五颗同色棋子连在一起

11111

活四

有两个连五点(即有两个点可以形成五),图中白点即为连五点

011110

冲四

有一个连五点

011112

0101110

0110110

 

活三

可以形成活四的三

01110

010110

眠三

只能够形成冲四的三

001112

010112

011012

10011

10101

2011102

    

======================================================================== MICROSOFT FOUNDATION CLASS LIBRARY : fir ======================================================================== AppWizard has created this fir application for you. This application not only demonstrates the basics of using the Microsoft Foundation classes but is also a starting point for writing your application. This file contains a summary of what you will find in each of the files that make up your fir application. fir.dsp This file (the project file) contains information at the project level and is used to build a single project or subproject. Other users can share the project (.dsp) file, but they should export the makefiles locally. fir.h This is the main header file for the application. It includes other project specific headers (including Resource.h) and declares the CFirApp application class. fir.cpp This is the main application source file that contains the application class CFirApp. fir.rc This is a listing of all of the Microsoft Windows resources that the program uses. It includes the icons, bitmaps, and cursors that are stored in the RES subdirectory. This file can be directly edited in Microsoft Visual C++. fir.clw This file contains information used by ClassWizard to edit existing classes or add new classes. ClassWizard also uses this file to store information needed to create and edit message maps and dialog data maps and to create prototype member functions. res\fir.ico This is an icon file, which is used as the application's icon. This icon is included by the main resource file fir.rc. res\fir.rc2 This file contains resources that are not edited by Microsoft Visual C++. You should place all resources not editable by the resource editor in this file. ///////////////////////////////////////////////////////////////////////////// For the main frame window: MainFrm.h, MainFrm.cpp These files contain the frame class CMainFrame, which is derived from CFrameWnd and controls all SDI frame features. ///////////////////////////////////////////////////////////////////////////// AppWizard creates one document type and one view: firDoc.h, firDoc.cpp - the document These files contain your CFirDoc class. Edit these files to add your special document data and to implement file saving and loading (via CFirDoc::Serialize). firView.h, firView.cpp - the view of the document These files contain your CFirView class. CFirView objects are used to view CFirDoc objects. ///////////////////////////////////////////////////////////////////////////// Other standard files: StdAfx.h, StdAfx.cpp These files are used to build a precompiled header (PCH) file named fir.pch and a precompiled types file named StdAfx.obj. Resource.h This is the standard header file, which defines new resource IDs. Microsoft Visual C++ reads and updates this file. ///////////////////////////////////////////////////////////////////////////// Other notes: AppWizard uses "TODO:" to indicate parts of the source code you should add to or customize. If your application uses MFC in a shared DLL, and your application is in a language other than the operating system's current language, you will need to copy the corresponding localized resources MFC42XXX.DLL from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources translated to German.) If you don't do this, some of the UI elements of your application will remain in the language of the operating system. /////////////////////////////////////////////////////////////////////////////
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值