【原创】A MATLAB version of the Renju chess(连珠, 五子棋)
开发环境:Matlab 7.6 (R2008a).下面摘录的是主函数的一段代码,运行该函数即可开始游戏。
[b]
[b][code]
function renju(varargin)
%RENJU A MATLAB version of the Renju chess
%该程序功能简介:
%1. 双人下五子棋,能够判胜负。
%2. 如果选中Hint 3 ,会画出黑白双方在六格之内所有可能形成3的点。
%3. Hint 4 和 Hint 5 的功能与Hint 3同理。
%4. 按一次Back,悔一步棋。
%5. 按下Restart,重新启动程序。
%
% See also mousedown, hint, plothint, plotchess.
%By:Ji Lin
%Email: linji@live.com
%Blog: http://linji526.spaces.live.com
%Date: 2008/05/26,2008/08/16
[/code][/b]
[/b]
下面图中是一道名为《城》的五子棋题目,黑从15开始可以连攻胜,有兴趣的不妨研究一下:
[attach]170242[/attach]
[color=darkgreen]最近修改(2008/8/18):去掉了胜利以后的提示框,修改了胜利以后报错的BUG[/color]
[[i] 本帖最后由 linji526 于 2008-8-24 13:26 编辑 [/i]] 附件中是打包成exe的文件,如果没有安装MATLAB,可以先下载安装
MCRInstaller.exe后直接运行。
[color=darkgreen]2008/8/24重新编译,去掉了[b]运行时的DOS黑窗口[/b][/color]
[[i] 本帖最后由 linji526 于 2008-8-24 13:29 编辑 [/i]] Is that possible to make an artifical agent programme ?
Computer VS Brain ?
回复 3# FreddyMusic 的帖子
其实我最初做的是一个可以人机对战的程序,但一直没有找到好的五子棋算法,自己尝试设计过一个算法,但由于其智能太低就放弃了,后来也没有花精力继续思考这个问题。为了不让这个程序长期只在自己的硬盘中,就修改成了现在的五子棋辅助程序共享出来。欢迎提供五子棋算法程序或思想至[email]linji@live.com[/email],如果找到合适的算法,我会努力将人机对战功能加入到程序中去。 I found something for you.
[url]http://demonstrations.wolfram.com/TicTacToe/[/url]
That's early work by Micheal Schreiber.
That demonstration is for three chess, but you may expand for 5 chess as well.
The essential thought is for find all answers as database, the algorithm is search or optimize for the win solution. Hope that helps.
Have fun.
讨论
可以用C编的程序导入吗!回复 5# FreddyMusic 的帖子
谢谢!TicTacToe总共只有9个格式,可以穷举,所以算法不难实现。
五子棋的棋局变化太多,我想无法采用穷举的办法。
回复 6# baa3befc 的帖子
C编的程序可以让Matlab调用,即混合编程,也可以改写成Matlab程序 [quote]原帖由 [i]linji526[/i] 于 2008-8-23 12:26 发表 [url=http://forum.simwe.com/redirect.php?goto=findpost&pid=1405689&ptid=843925][img]http://forum.simwe.com/images/common/back.gif[/img][/url]谢谢!
TicTacToe总共只有9个格式,可以穷举,所以算法不难实现。
五子棋的棋局变化太多,我想无法采用穷举的办法。 [/quote]
You can define a gird table Eg. 10 Height X10 Width =100
Every gird has three statue, Black / White / Blank.
That is N[3^100] = 5.15378*10^47 ( Of course that's huge database, but not that crazy ).
If the constrain and input is given, it can always make list the answer.
Any better solution ? If 8X8 Grid. it's N[3^(8^2)] = 3.43368*10^30 It can be evaluated by 10! or something, I am not quite sure. need review books.
But when it has win-lost result. it's finished. ( with blank )
If all grid is filled up, it's finished (without blank ) [quote]原帖由 [i]FreddyMusic[/i] 于 2008/8/25 13:01 发表 [url=http://forum.simwe.com/redirect.php?goto=findpost&pid=1406719&ptid=843925][img]http://forum.simwe.com/images/common/back.gif[/img][/url]
It can be evaluated by 10! or something, I am not quite sure. need review books.
But when it has win-lost result. it's finished. ( with blank )
If all grid is filled up, it's finished (without bla ... [/quote]
感谢FreddyMusic,我最近没空继续思考算法的实现问题了。
希望有兴趣的朋友能够实现一个人工智能较高的五子棋算法。
期望将来能够看到一款能与五子棋软件BlackStone(黑石)一决高下的Matlab版的五子棋开源软件!
页:
[1]