資源簡介
這是我們學院的08級課程設計,是用MFC做的國際象棋,里面結構比較合理,算法非常好,適合廣大初學者使用,希望大家喜歡。
代碼片段和文件信息
#include???“stdafx.h“?
#include?“chessgo.h“
#include
extern?int?chess[8][8];
int?Board1::check_rook_move?(int?x0int?y0int?xint?y)
{
bool?can_move=false;
if?(((chess[x0][y0]==21||chess[x0][y0]==24)&&(chess[x][y]==0||chess[x][y]==16||
chess[x][y]==11||chess[x][y]==12||chess[x][y]==13||chess[x][y]==14||chess[x][y]==15))
||((chess[x0][y0]==11||chess[x0][y0]==14)&&(chess[x][y]==0||chess[x][y]==26||chess[x][y]==21||
chess[x][y]==22||chess[x][y]==23||chess[x][y]==24||chess[x][y]==25)))
{
can_move=true;
if(y==y0)??????????????????//?車橫向移動
{
if?(x>(x0+1))
{
for(int?j=(x0+1);j {
if?(chess[j][y]!=0){
can_move=false;}
}
}
else?if?(x<(x0-1))
{
for(int?j=x+1;j {?
if(chess[j][y]!=0){
can_move=false;}
}
}
else?{}
}
else?if?(x==x0)????????????//車縱向移動
{?
if(y>(y0+1))
{
for?(int?j=y0+1;j {?
if(chess[x][j]!=0){
can_move=false;}
}
}
else?if(y<(y0-1))
{
for(int?j=y+1;j {
if?(chess[x][j]!=0)
can_move=false;
}
}
else{}
}
else?can_move=false;
}
return??can_move;
}
int?Board1::check_knight_move(int?x0int?y0int?xint?y)
{
bool?can_move=false;
if(?(?(chess[x0][y0]==22&&(chess[x][y]==0||chess[x][y]==16||chess[x][y]==11||
chess[x][y]==12||chess[x][y]==13||chess[x][y]==14||chess[x][y]==15?)?)
||(?chess[x0][y0]==12&&?(?chess[x][y]==0||chess[x][y]==26||chess[x][y]==21||
chess[x][y]==22||chess[x][y]==23||chess[x][y]==24||chess[x][y]==25?)?)?)?)
{
//馬走日字
if((abs(x-x0)==2&&abs(y-y0)==1)||(abs(x-x0)==1&&abs(y-y0)==2))
{
can_move=true;
}
}?
return?can_move;
}
int?Board1::check_bishop_move(int?x0int?y0int?xint?y)
{
bool?can_move=false;
//斜走斜線,且中間都為空格
if(((chess[x0][y0]==13||chess[x0][y0]==14)&&(chess[x][y]==0||chess[x][y]==26||chess[x][y]==21||
chess[x][y]==22||chess[x][y]==23||chess[x][y]==24||chess[x][y]==25))||((chess[x0][y0]==23||
chess[x0][y0]==24)&&(chess[x][y]==0||chess[x][y]==16||chess[x][y]==11||chess[x][y]==12||
chess[x][y]==13||chess[x][y]==14||chess[x][y]==15)))
{?
can_move=true;
if(abs(x-x0)==abs(y-y0))
{
int?mn;
if?(x>x0&&y>y0)
{
for(m=x0+1n=y0+1;m {?
if(chess[m][n]!=0){
can_move=false;}
}
}
else?if?(xy0)
{
for(m=x0-1n=y0+1;m>x&&n {
if(chess[m][n]!=0){
can_move=false;}
}
}
else?if?(x>x0&&y {
for?(m=x0+1n=y0-1;my;m++n--)
{
if(chess[m][n]!=0){
can_move=false;}
}
}
else?if?(x {
for?(m=x0-1n=y0-1;m>x&&n>y;m--n--)
{
if?(chess[m][n]!=0){
can_move=false;}
}
}
else?can_move=true;
}
else
can_move=false;
}
return?can_move;
}
int?Board1::check_Queen_move(int?x0int?y0int?xint?y)
{
//后兼具車和
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5131??2009-06-06?17:47??國際象棋\national\chessgo.cpp
?????文件????????468??2009-06-04?13:39??國際象棋\national\chessgo.h
?????文件???????1673??2009-06-05?18:29??國際象棋\national\D.cpp
?????文件???????1186??2009-05-26?19:18??國際象棋\national\D.h
?????文件???????1217??2009-05-25?20:07??國際象棋\national\Diff.h
?????文件???????1289??2009-05-26?19:16??國際象棋\national\hero.cpp
?????文件???????1254??2009-05-26?18:56??國際象棋\national\hero.h
?????文件???????1127??2009-05-26?15:29??國際象棋\national\lasthero.cpp
?????文件???????1224??2009-05-26?15:29??國際象棋\national\lasthero.h
?????文件???????4490??2009-06-07?17:03??國際象棋\national\national.clw
?????文件???????2093??2009-06-02?21:46??國際象棋\national\national.cpp
?????文件????????539??2009-05-23?12:59??國際象棋\national\national.dsw
?????文件???????1346??2009-05-23?12:59??國際象棋\national\national.h
?????文件?????263168??2009-06-07?17:09??國際象棋\national\national.ncb
?????文件????????884??2009-06-07?17:07??國際象棋\national\national.plg
?????文件???????3615??2009-05-23?12:59??國際象棋\national\ReadMe.txt
?????文件???????1054??2009-05-23?12:59??國際象棋\national\StdAfx.h
?????文件??????????0??2009-05-24?00:31??國際象棋\national\VA_C__Documents?and?Settings_Administrator_Local?Settings_Application?Data_VisualAssist_vc6_history_
?????文件???????1223??2009-06-07?15:05??國際象棋\national\diffore.h
?????文件???????1325??2009-06-07?15:16??國際象棋\national\diffcanuse.h
?????文件???????1610??2009-06-07?15:25??國際象棋\national\diffcanuse.cpp
?????文件???????8357??2009-06-07?15:33??國際象棋\national\national.dsp
?????文件???????2815??2009-06-07?15:33??國際象棋\national\resource.h
?????文件???????1295??2009-06-07?15:34??國際象棋\national\shengji.h
?????文件??????14156??2009-06-07?15:40??國際象棋\national\national.rc
?????文件????1440054??2009-06-04?20:01??國際象棋\national\res\back111.bmp
?????文件????1440054??2009-06-04?19:57??國際象棋\national\res\back3.bmp
?????文件????3470020??2009-05-29?21:59??國際象棋\national\res\backgroundmusic.mp3
?????文件???????1078??2005-05-21?02:53??國際象棋\national\res\chess.ico
?????文件????????397??2005-05-21?02:53??國際象棋\national\res\chess.rc2
............此處省略61個文件信息
評論
共有 條評論