/********************************
* Blokus Baicai Seeker Release *
* by coolypf *
* 2009-05-22 09:24 *
********************************/
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#define Blank -1
int Me,iStart=19;
const int soBlock=1,
soBlank=3,
soFix=30,
soAngle=75;
const char Piece[21][5][5]=
{
{
{1,0,0,0,0},
{0,0,0,0,0},
{0,0,0,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,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,1,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,1,1,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,1,1,1},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,0,0,0},
{1,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,0,0,0},
{1,1,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,0,0,0},
{1,1,0,0,0},
{1,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,0,0,0},
{0,1,1,0,0},
{0,0,1,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,0,0,0},
{1,0,0,0,0},
{1,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,0,0,0},
{1,0,0,0,0},
{1,0,0,0,0},
{1,0,0,0,0},
{0,0,0,0,0}
},
{
{1,0,0,0,0},
{1,1,0,0,0},
{1,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,0,0,0,0},
{1,1,0,0,0},
{1,0,0,0,0},
{1,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,0,0,0},
{1,0,0,0,0},
{1,1,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{0,1,0,0,0},
{1,1,1,0,0},
{0,1,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,0,0,0,0},
{1,1,1,0,0},
{1,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{1,1,1,0,0},
{1,0,0,0,0},
{1,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{0,1,1,0,0},
{1,1,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{0,1,1,0,0},
{1,1,0,0,0},
{0,1,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{0,1,1,0,0},
{0,1,0,0,0},
{1,1,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
},
{
{0,1,1,1,0},
{1,1,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
}
};
const char soSingle[21]=
{
1,3,6,8,9,5,8,
9,9,7,9,7,9,9,
9,9,9,7,9,9,9
};
char b[20][20],p[21][8][5][5];
int step=0,startx,starty;
bool unused[4][21];
bool IsAngle(char [][20],int,int,int);
bool CanPut(char [][20],int,int,int,int,int);
bool CanPutStart(int,int,int,int);
void Init();
void Backup(char [][20],const char [][20]);
int SimpleEvaluate(char [][20],int,int,int,int,int);
int MyEvaluate(char [][20]);
void AI();
void turn(char [][5],const char [][5],int);
void PutStart();
void Put(int,char [][20],int,int,int,int);
int cBlanks(char [][20],bool [][20],int,int,int);
int main()
{
Init();
int n,x,y,p,i,d;
string cmd;
while(1)
{
cin>>cmd;
if(cmd=="[end]") break;
else if(cmd=="[start]")
{
cin>>startx>>starty;
cin>>cmd;
cin>>n;
if(startx&
角斗士(Blokus)博弈程序
最新推荐文章于 2024-09-02 08:14:11 发布
这是一个用C++实现的Blokus博弈程序,由coolypf编写。程序包括游戏初始化、棋盘操作、AI算法等功能,通过读取命令行输入进行游戏流程控制。AI部分采用了基于评估函数的搜索策略,考虑了棋子位置、相邻角度等因素。
摘要由CSDN通过智能技术生成