象棋程式是让乎耐人跟电脑下棋的,下面我给你介绍,欢迎阅读。
棋类游戏一般都能建立起数学模型,电脑做的只是判断这一步棋的下一岁态春步的每种可能走法,以及每种走法的下一步……以此类推,也就是说电脑能判断下一步怎么走,才能对自己在下下一步以致以后的多少步内都对自己有利。随着电脑预测的步数的增加,计算量成指数级增加,计算时间也会更长,这闭租样,除了棋类程式的演算法因素以外,考验的就是计算机的CPU计算速度了~所以要在电脑的“预测能力”和等待时间之间取一个折中的步数,比如20步。1997年IBM的“深蓝”战败世界棋王卡西帕罗夫,就是因为他的计算机的计算能力是当时世界顶尖的。
中国象棋原始码-C语言小程式
*--------------------che#include"dos.h"#include"stdio.h&qu/*----------------------#defineRED7#defineBLACK14#definetrue1#definefalse0#defineSELECT0#defineMOVE*--------------------chess.c----------------------*/#include "dos.h"#include "stdio.h"/*----------------------------------------------------*/#define RED 7#define BLACK 14#define true 1#define false 0#define SELECT 0#define MOVE 1#define RED_UP 0x1100#define RED_DOWN 0x1f00#define RED_LEFT 0x1e00#define RED_RIGHT 0x2000#define RED_DO 0x3900#define RED_UNDO 0x1000#define BLACK_UP 0x4800#define BLACK_DOWN 0x5000#define BLACK_LEFT 0x4b00#define BLACK_RIGHT 0x4d00#define BLACK_DO 0x1c00#define BLACK_UNDO 0x2b00#define ESCAPE 0x0100#define RED_JU 1#define RED_MA 2#define RED_XIANG 3#define RED_SHI 4#define RED_JIANG 5#define RED_PAO 6#define RED_BIN 7#define BLACK_JU 8#define BLACK_MA 9#define BLACK_XIANG 10#define BLACK_SHI 11#define BLACK_JIANG 12#define BLACK_PAO 13#define BLACK_BIN 14/*----------------------------------------------------*/int firsttime=1int savemodechar page_new=0,page_old=0int finish=false,turn=BLACK,winner=0int keyint redstate=SELECT,blackstate=SELECTint board[10][9]/*----------------------------------------------------*/char *chessfile[15]={"","bmp\\rju.wfb", "bmp\\rma.wfb", "bmp\\rxiang.wfb","bmp\\rshi.wfb","bmp\\rjiang.wfb","bmp\\rpao.wfb","bmp\\rbin.wfb","bmp\\bju.wfb", "bmp\\bma.wfb", "bmp\\bxiang.wfb","bmp\\bshi.wfb","bmp\\bjiang.wfb","bmp\\bpao.wfb","bmp\\bbin.wfb"}char *boardfile[10][9]={{"bmp\\11.wfb","bmp\\1t.wfb","bmp\\1t.wfb","bmp\\14.wfb","bmp\\15.wfb","bmp\\16.wfb","bmp\\1t.wfb","bmp\\1t.wfb","bmp\\19.wfb"},{"bmp\\21.wfb","bmp\\2c.wfb","bmp\\2c.wfb","bmp\\24.wfb","bmp\\25.wfb","bmp\\26.wfb","bmp\\2c.wfb","bmp\\2c.wfb","bmp\\29.wfb"},{"bmp\\21.wfb","bmp\\3a.wfb","bmp\\3t.wfb","bmp\\34.wfb","bmp\\3t.wfb","bmp\\36.wfb","bmp\\3t.wfb","bmp\\3a.wfb","bmp\\29.wfb"},{"bmp\\41.wfb","bmp\\4t.wfb","bmp\\4a.wfb","bmp\\4t.wfb","bmp\\4a.wfb","bmp\\4t.wfb","bmp\\4a.wfb","bmp\\4t.wfb","bmp\\49.wfb"},{"bmp\\51.wfb","bmp\\52.wfb","bmp\\5t.wfb","bmp\\54.wfb","bmp\\5t.wfb","bmp\\56.wfb","bmp\\5t.wfb","bmp\\58.wfb","bmp\\59.wfb"},{"bmp\\61.wfb","bmp\\62.wfb","bmp\\6t.wfb","bmp\\64.wfb","bmp\\6t.wfb","bmp\\66.wfb","bmp\\6t.wfb","bmp\\68.wfb","bmp\\69.wfb"},{"bmp\\71.wfb","bmp\\7t.wfb","bmp\\7a.wfb","bmp\\7t.wfb","bmp\\7a.wfb","bmp\\7t.wfb","bmp\\7a.wfb","bmp\\7t.wfb","bmp\\79.wfb"},{"bmp\\81.wfb","bmp\\8a.wfb","bmp\\8t.wfb","bmp\\84.wfb","bmp\\85.wfb","bmp\\86.wfb","bmp\\8t.wfb","bmp\\8a.wfb","bmp\\89.wfb"},{"bmp\\91.wfb","bmp\\9t.wfb","bmp\\9t.wfb","bmp\\9t.wfb","bmp\\95.wfb","bmp\\9t.wfb","bmp\\9t.wfb","bmp\\9t.wfb","bmp\\99.wfb"},{"bmp\\101.wfb","bmp\\102.wfb","bmp\\102.wfb","bmp\\104.wfb","bmp\\105.wfb","bmp\\106.wfb","bmp\\108.wfb","bmp\\108.wfb","bmp\\109.wfb"}}char cursor[14][14]={0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,255,255,255,255,255,255,255,0,0,1,1,1,1,0,255,255,255,255,255,255,0,0,1,1,1,1,1,0,255,255,255,255,255,255,0,0,1,1,1,1,1,0,255,255,255,255,255,255,255,0,0,1,1,1,1,0,255,255,255,255,255,255,255,255,0,0,1,1,1,0,255,255,255,255,255,255,255,255,255,0,0,1,1,0,255,255,0,255,255,255,255,255,255,255,0,0,1,0,255,0,1,1,0,255,255,255,255,255,255,255,0,0,0,1,1,1,1,0,255,255,255,255,255,0,1,0,1,1,1,1,1,1,0,255,255,255,0,1,1,1,1,1,1,1,1,1,1,0,255,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1}struct pos{int xint y}position[10][9],redcurpos,redtemppos,redoldpos,blackcurpos,blacktemppos,blackoldpos/*----------------------------------------------------*/selectpage***register char page*** /*换页函式*/{union REGS rr.x.ax=0x4f05r.x.bx=0r.x.dx=page/*选择页面*/int86***0x10,&r,&r***}unsigned char set_SVGA_mode***int vmode*** /*设定SVGA萤幕模式*/{union REGS rr.x.ax=0x4f02r.x.bx=vmodeint86***0x10,&r,&r***return***r.h.ah***}unsigned int get_SVGA_mode****** /*获取当前SVGA萤幕模式*/{union REGS rr.x.ax=0x4f03int86***0x10,&r,&r***return***r.x.bx***}drawbmp***int start_x,int start_y,char filename[]***{char buffer[640]int i,j,k,n,r,g,b,width,lengthlong positionFILE *fpif******fp=fopen***filename,"rb"******==NULL***{printf***"Error! Can't open file!"***getch******return}fseek***fp,28,SEEK_SET***fread***&i,2,1,fp***if***i!=8*** /*检查是否为256色点阵图*/{puts***"Error!Can't find bitmap!"***fclose***fp***getch******exit***0***}fseek***fp,18,SEEK_SET***fread***&width,4,1,fp***fread***&length,4,1,fp***if***firsttime***{fseek***fp,54,SEEK_SET***for***i=0i<256i++*** /*按照该图片的DAC色表设定色彩暂存器*/{b=fgetc***fp***g=fgetc***fp***r=fgetc***fp***/*获取R、G、B分量*/outportb***0x3c8,i***outportb***0x3c9,r>>2***/*右移是要转化为VGA的6位暂存器形式*/ outportb***0x3c9,g>>2***outportb***0x3c9,b>>2***fgetc***fp***}}elsefseek***fp,300,SEEK_SET***k=***width%4***?***4-width%4***:0/*宽度修正值*/for***j=length-1+start_xj>=start_xj--***{fread***buffer,width,1,fp***for***i=start_y,n=0i
是《象棋奇兵》。该游戏基于Bitboard设计,棋力高超稳定,曾荣获2005年第十届奥林匹克中国象棋电脑软件大赛冠军。
《象棋奇兵》在推出3.6免费版试用获得不错反响后,于2004年发布了象棋奇兵1.01版开始进行商业化,面向市场渗岁樱进行发售,此后又陆续发布了1.02、1.04、2.2、2.3、2.4、3.0、4.0、5.0、6.0等多个版本。
从1.02版本开始,象棋奇兵推出了高级版本,开始支持多线程运算,是为象棋软件开先河,其高超的棋力、全雀困面的功能受到棋友的广泛好评。
该软件的主要功能:
1、棋谱研究。能够读取pgn、xqn等不同格式的中国象棋棋谱文件,可以方便的丛丛进行打谱研究。支持棋谱和局面剪切板 *** 作。
2、人机对战。具有很强的人工智能,方便灵活的时间设置和强大的棋步分析功能。
3、摆设残局。方便快捷的残局摆设功能,丰富的快捷键,轻松实现让子和让先对弈的功能。
4、网络对战。内置弈天网站自动对弈功能,可以连接到弈天网站进行自动对弈。同时利用“弈星”象棋连线程序,能够让本软件连接到任何象棋网站进行自动对弈。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)