资源简介
中国象棋基本实现,规则全完成,附加棋局匹配,从文件读入走起步骤
代码片段和文件信息
#include
#include
#include
using namespace std;
extern int x[11][12];//列行
void printplate();
int red_go(int int int int);
int black_go(int int int int);
struct Temp_chess{
int value;
bool valid;
};
struct Temp_P{
Temp_chess temp_plate[10][11];
bool valid;
};
extern Temp_P t[64];
extern int repeat1 repeat2;
int pos[16];
struct Pos_match{
int x1 y1 x2 y2;
};
Pos_match posmatch[4];
struct Point{ int x y; };
Point point[72];
int step;
int maxpoint;
int redfull blackfull;
void init_temp_plate();
int plate_equal(int a1 int a2);
void plate_to_plate(int flag);
int equal_judge(int index);
int match_plate(char* file);
int plate_unequal(int a1 int a2 int n){
int count = 0;
for (int i = 1; i < 10; i++){
for (int j = 1; j < 11; j++){
if (t[a1].temp_plate[i][j].value != t[a2].temp_plate[i][j].value){
count++; //cout << t[a1].temp_plate[i][j].value <<“ “<< t[a2].temp_plate[i][j].value<<“ “;
if (count > n*2){
return count;
}
pos[count * 2 - 2] = i;
pos[count * 2 - 1] = j;
}
}
}
//for (int k = 0; k < 16; k++){cout << pos[k] << endl;}
cout << count << “个地方不一样“ << endl;
return count;
}
int judge_value(int a1 int a2 int n){
int count1 = 0; int count2 = 0;
for (int i = 0; i < n*2; i++){
if (t[a1].temp_plate[pos[i * 2]][pos[i * 2 + 1]].value > 0 || t[a2].temp_plate[pos[i * 2]][pos[i * 2 + 1]].value > 0)
count1++;
if (count1 > n * 2){
printf(“有多于%d个对象需要变动,所以前者不可以到达后者格局。\n“ n); return 0;
}
for (int j = 0; j < n*2; j++){
if (t[a1].temp_plate[pos[i * 2]][pos[i * 2 + 1]].value > 0){
//cout << t[a1].temp_plate[pos[i * 2]][pos[i * 2 + 1]].value << “ “ << t[a2].temp_plate[pos[j * 2]][pos[j * 2 + 1]].value << “ “< if ((t[a1].temp_plate[pos[i * 2]][pos[i * 2 + 1]].value == t[a2].temp_plate[pos[j * 2]][pos[j * 2 + 1]].value)
&& t[a2].temp_plate[pos[j * 2]][pos[j * 2 + 1]].valid ==0){
posmatch[count2].x1 = pos[i * 2];
posmatch[count2].y1 = pos[i * 2 + 1];
posmatch[count2].x2 = pos[j * 2];
posmatch[count2].y2 = pos[j * 2 + 1];
count2++;
t[a2].temp_plate[pos[j * 2]][pos[j * 2 + 1]].valid = 1;
}
}
}
}
if (count1 > count2 * 2){ printf(“后者棋局棋子数比前者多,所以不可以。%d%d\n“ count1 count2); return 0; }
return count2;
}
void posmatch_change(){
Pos_match t; int m;
for (int i = 3; i >=0; i--){
if (posmatch[i].x1 == 0)
m = i;
}
for (int i = 0; i < m; i++){
if (x[posmatch[i].x1][posmatch[i].y1] == 12 || x[posmatch[i].x1][posmatch[i].y1] == 13
|| x[posmatch[i].x1][posmatch[i].y1] == 22 || x[posmatch[i].x1][posmatch[i].y1] == 23){
t.x1 = posmatch[i].x1; t.y1 = posmatch[i].y1;
t.x2 = posmatch[i].x2; t.y2 = posmatch[i].y2;
for (int j = i; j < m; j++){
posmatch[j].x1 = posmatch[j + 1].x1; posmatch[j].y1 = posmatch[j + 1].y1;
posmatch[j].x2 = posmatch[j + 1].x2; posmatch[j].y2 = posmatch[j + 1].y2;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-02-21 10:44 Chinesechess\
目录 0 2015-01-13 14:04 Chinesechess\Chinesechess\
文件 4219 2015-01-10 15:51 Chinesechess\Chinesechess\Chinesechess.vcxproj
文件 1225 2015-01-10 15:51 Chinesechess\Chinesechess\Chinesechess.vcxproj.filters
目录 0 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\
文件 323 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\Chinesechess.log
目录 0 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\Chinesechess.tlog\
文件 50104 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\Chinesechess.tlog\CL.read.1.tlog
文件 8428 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\Chinesechess.tlog\CL.write.1.tlog
文件 153 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\Chinesechess.tlog\Chinesechess.lastbuildstate
文件 4332 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\Chinesechess.tlog\cl.command.1.tlog
文件 2550 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\Chinesechess.tlog\li
文件 2974 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\Chinesechess.tlog\li
文件 686 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\Chinesechess.tlog\li
文件 188863 2015-01-13 12:04 Chinesechess\Chinesechess\Debug\change_to_plate.obj
文件 131401 2014-12-17 21:35 Chinesechess\Chinesechess\Debug\chess.obj
文件 151446 2014-12-21 10:48 Chinesechess\Chinesechess\Debug\chessclass.obj
文件 152738 2014-12-22 00:53 Chinesechess\Chinesechess\Debug\chessplate.obj
文件 154395 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\game.obj
文件 288751 2015-01-12 23:36 Chinesechess\Chinesechess\Debug\game_file.obj
文件 138905 2015-01-12 20:59 Chinesechess\Chinesechess\Debug\main.obj
文件 396288 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\vc120.idb
文件 430080 2015-01-13 14:04 Chinesechess\Chinesechess\Debug\vc120.pdb
文件 8145 2015-01-13 12:04 Chinesechess\Chinesechess\change_to_plate.cpp
文件 9592 2014-12-21 00:41 Chinesechess\Chinesechess\chessclass.cpp
文件 1366 2014-12-21 10:48 Chinesechess\Chinesechess\chessclass.h
文件 7779 2014-12-22 00:53 Chinesechess\Chinesechess\chessplate.cpp
文件 9329 2015-01-13 14:04 Chinesechess\Chinesechess\game.cpp
文件 5455 2015-01-12 23:36 Chinesechess\Chinesechess\game_file.cpp
文件 1519 2015-01-12 20:58 Chinesechess\Chinesechess\main.cpp
文件 8454144 2015-02-21 10:44 Chinesechess\Chinesechess.sdf
............此处省略16个文件信息
- 上一篇:jpeg压缩纯C语言实现
- 下一篇:后方交会C++程序
相关资源
- 中国象棋对弈(MFC单机版)
- C/C++中国象棋程序入门与提高 part 22
- C++编写中国象棋源代码
- C++Builder程序设计范例中国象棋.
- c语言编写中国象棋人人对战graphic.h
- 中国象棋 陶善文源码 VC++2013 MFC 游戏
- VC++ 中国象棋程序源代码
- C++中国象棋人机下棋 高智商版
- 用c语言编写的一个中国象棋
- C++中国象棋编码
- 基于QT的用C++编写的中国象棋软件源代
- 在n x n棋盘有n x n个格点的棋盘的某个
- 中国象棋源代码(c语言版)
- FunCode平台下中国象棋游戏
- vc++ 网络编程中国象棋
- 中国象棋VC6.0编写源程序代码
- 中国象棋AI算法 C/C++
- 中国象棋源码
评论
共有 条评论