资源简介
包括人机对战、人人对战,电脑AI还行,先手有禁手(三三、四四、长连)

代码片段和文件信息
#include “TABLE.H“
#include “JUDGE.H“
#include “AI.H“
char cycle()
{
cout<<“Ps:输入坐标下子,由于屏幕背景原因,看起来是白色的棋子是黑棋;\n\tA-E对应10-14,请勿输入字母;\n\t\t先输入行数(纵坐标),再输入列数(横坐标),中间用空格隔开;\n“< int input[15][15];
for(int i = 0 ; i < 15 ; i++ ){
for(int j = 0 ; j < 15 ; j++ ){
input[i][j] = 0 ;
}
}
Table fivetable(input);
fivetable.display();
cout<<“\nplease select mode:\n\t1. single-player game against computer.\n\t2. multiple-player game with your friends.“< int mode;
cin>>mode;
Judge judgeblack( 1 ) ;
Judge judgewhite( 2 ) ;
int count = 1 ;
int line column ;
char anykey ;
//////////////////////////////// 双人游戏模式 ///////////////////////////////////
if( mode == 2 )
{
while( 225-count > 0 ){
if( count%2 ){
cout<<“黑棋下子“< do{
cin>> line >> column ;
}while( !fivetable.set( line column 1) );
if( judgeblack.longlink( fivetable ) ){
fivetable.displaygameover( line column );
cout<<“黑棋长连禁手,白棋胜“< cout<<“\n按任意键继续,按0退出\n“< cin>>anykey ;
return anykey ;
}
if( judgeblack.fivelink( fivetable ) ){
fivetable.displaygameover( line column );
cout<<“黑棋五连,黑棋胜“< cout<<“\n按任意键继续,按0退出\n“< cin>>anykey ;
return anykey ;
}
if( judgeblack.huosan( fivetable ) > 1 ){
fivetable.displaygameover( line column );
cout<<“黑棋三三禁手,白棋胜“< cout<<“\n按任意键继续,按0退出\n“< cin>>anykey ;
return anykey ;
}
if( judgeblack.si( fivetable ) > 1 ){
fivetable.displaygameover( line column );
cout<<“黑棋四四禁手,白棋胜“< cout<<“\n按任意键继续,按0退出\n“< cin>>anykey ;
return anykey ;
}
fivetable.display();
}
else{
cout<<“白棋下子“< do{
cin>> line >> column ;
}while( !fivetable.set( line column 2) );
if( judgewhite.fivelink( fivetable ) ){
fivetable.displaygameover( line column );
cout<<“白棋五连,白棋胜“< cout<<“\n按任意键继续,按0退出\n“< cin>>anykey ;
return anykey ;
}
// cout< fivetable.display();
}
count++ ;
}
cout<<“和棋“< cout<<“\n按任意键继续,按0退出\n“< cin>>anykey ;
return anykey ;
}
/////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// 单人游戏模式 ///////////////////////////////////
if( mode == 1 )
{
cout<<“1.玩家先下\n2.电脑先下“< int xianshou ;
cin>>xianshou ;
int position ;
///////////////// 玩家先手 //////////////////
if( xianshou == 1 )
{
Ai white( 2 ) ;
while( 225-count > 0 ){
if( count%2 ){
do{
cin>> line >> column ;
}while( !fivetable.set( line column 1) );
if( judgeblack.longlink( fivetable ) ){
fivetable.displaygameover( line column );
cout<<“黑棋长连禁手,you lose“<
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 30549 2010-12-24 10:59 five\AI.CPP
文件 252 2010-12-19 13:49 five\AI.H
文件 169907 2010-12-24 11:06 five\Debug\AI.obj
文件 618558 2010-12-24 11:06 five\Debug\five.exe
文件 826700 2010-12-24 11:06 five\Debug\five.ilk
文件 186940 2010-12-16 16:28 five\Debug\five.pch
文件 1393664 2010-12-24 10:59 five\Debug\five.pdb
文件 19987 2010-12-19 13:49 five\Debug\JUDGE.obj
文件 208404 2010-12-20 01:06 five\Debug\main.obj
文件 50975 2010-12-19 13:49 five\Debug\TABLE.obj
文件 107520 2010-12-24 11:06 five\Debug\vc60.idb
文件 118784 2010-12-24 10:59 five\Debug\vc60.pdb
文件 4614 2010-12-18 17:13 five\five.dsp
文件 516 2010-12-16 13:58 five\five.dsw
文件 66560 2010-12-24 11:06 five\five.ncb
文件 49664 2010-12-24 11:06 five\five.opt
文件 935 2010-12-24 11:06 five\five.plg
文件 8065 2010-12-18 17:07 five\JUDGE.CPP
文件 425 2010-12-18 22:16 five\JUDGE.H
文件 6944 2010-12-20 01:04 five\main.cpp
文件 5384 2010-12-18 17:07 five\TABLE.CPP
文件 349 2010-12-18 22:16 five\TABLE.H
目录 0 2010-12-24 10:59 five\Debug
目录 0 2010-12-24 11:06 five
----------- --------- ---------- ----- ----
3875696 24
- 上一篇:双语版C++苏小红课后习题参考
- 下一篇:md5加密算法 C语言经过测试验证完整版
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
评论
共有 条评论