QQ农场外挂开发实践

来源:互联网 发布:mac msg文件怎么打开 编辑:程序博客网 时间:2024/04/30 11:18

QQ连连看分析: (注:此数据为非最大化时的数据2007年10月13日测试有效)
     连连看游戏区中的方块由内部小方块和外部边框组成,如下图
                       (不能显示,就跟汉字回一样)

分析数据,或者说是关键数据就在内部的方块中.经过我严格测试,得到如下结论:内部小方块宽24(屏幕坐标单位),高28,相临两块内部小块距7;
数据区,TopLeft=17+(n-1)*31
       Top=184+(n-1)*35
在知道这些数据之后,可以根据游戏区域里面的颜色建立一个矩阵,通知过判断矩阵就可以知道哪些能消去哪些不能消去。以下是用C语言写的判断能否连接的代码。主要思路如下:
如果两块之前没有其它块,表明它们是直连,若没有其它块,但它们是水平关系或竖直关系且中间为空白,表明也是直连关系。若不符合上述条件,则取所在点旁边的空点,若两个块的空点有相交,则表明它们可以有一个拐点的情况下消去。若不符合上术两条件,则选取一个关键点的空点做为关键点,再求此点的空部集合,若有空点与另一点的空点集合相交,说明可以用两个拐点连接,若不能,再取其它空点,直到取完为止。
这个好像不太容易用语言表述,看代码吧。
#include "stdafx.h"
#define M  4
#define N  5
#define BLANK 0
int map[11][19];
struct Point
{
 int x;
 int y;
};
Point arr1[209];
int arr1Len=0;
Point arr2[209];
int arr2Len=0;
//为测试数据赋值,这时为测试,在程序中将自动赋值
void InitArray()
{
 for(int i=0;i<M;i++)
  for(int j=0;j<N;j++)
   map[i][j]=0;
 map[1][1]=1;
 //map[1][2]=2;
 map[1][3]=2;
 map[2][1]=3;
 map[2][3]=4;
 //map[2][1]=3;
 map[3][1]=1;
 map[3][3]=1;
 map[3][2]=6;
}
//若有两个点相同,说明数组有相同点,返回真.此方法用来判断空点集是否相交
bool IsShare(Point* a1,int a1Len,Point* a2,int a2Len)
{
 bool result=false;
 for(int i=0;i<a1Len;i++)
  for(int j=0;j<a2Len;j++)
   if(a1[i].x==a2[j].x&&a1[i].y==a2[j].y)
    result=true;
 return result;
}
void ShowArray(Point* aaaa,int len)
{
 for(int i=0;i<len;i++)
  printf("(%d,%d)上的值%d/n",aaaa[i].x,aaaa[i].y,map[aaaa[i].x][aaaa[i].y]);
}
//若直连,则返回真
bool IsDirectLink(int x1,int y1,int x2,int y2)
{
 if(x1==x2)
 {
  int miny=y1+1;
  while(map[x1][miny]==BLANK)
   miny++;
  if(miny==y2)
   return true;
  else
   return false;
 }
    if(y1==y2)
 {
  int minx=x1+1;
  while(map[minx][y1]==BLANK)
   minx++;
  if(minx==x2)
   return true;
  else
   return false;
 }
 return false;
 
}
//此函数找出空点***************************此方法测试成功*******************
int FindEmpty(int x,int y,Point* arr)
{
 int count=0;
 int pos=x-1;
 while(0<=pos&&pos<M&&map[pos][y]==BLANK)
 {
  arr[count].x=pos;
  arr[count].y=y;
  pos--;
  count++;
 }
 pos=x+1;
 while(0<=pos&&pos<M&&map[pos][y]==BLANK)
 {
  arr[count].x=pos;
  arr[count].y=y;
  pos++;
  count++;
 }
 pos=y-1;
 while(0<=pos&&pos<N&&map[x][pos]==BLANK)
 {
  arr[count].x=x;
  arr[count].y=pos;
  pos--;
  count++;
 }
 pos=y+1;
 while(0<=pos&&pos<N&&map[x][pos]==BLANK)
 {
  arr[count].x=x;
  arr[count].y=pos;
  pos++;
  count++;
 }
 return count;
}
bool IndirectLink(int x1,int y1,int x2,int y2)
{
 int pos=0;
 Point ar1[209];
 int ar1Len=0;
 Point ar2[209];
 int ar2Len=0;
 //如果两点是上下且非直连关系
 //if(y1==y2)
 //{
  pos=y1-1;
  while(0<=pos&&pos<N&&map[x1][pos]==BLANK)
  {
   ar1Len=FindEmpty(x1,pos,ar1);
   ar2Len=FindEmpty(x2,y2,ar2);
   if(IsShare(ar1,ar1Len,ar2,ar2Len))
    return true;
   pos--;
  }
  pos=y1+1;
  while(0<=pos&&pos<N&&map[x1][pos]==BLANK)
  {
   ar1Len=FindEmpty(x1,pos,ar1);
   ar2Len=FindEmpty(x2,y2,ar2);
   if(IsShare(ar1,ar1Len,ar2,ar2Len))
    return true;
   pos++;
  }
 //}
 //如果两点是左右且非直连关系
 //if(x1==x2)
 //{
  pos=x1-1;
  while(0<=pos&&pos<M&&map[pos][y1]==BLANK)
  {
   ar1Len=FindEmpty(pos,y1,ar1);
   ar2Len=FindEmpty(x2,y2,ar2);
   if(IsShare(ar1,ar1Len,ar2,ar2Len))
    return true;
   pos--;
  }
  pos=x1+1;
  while(0<=pos&&pos<M&&map[pos][y1]==BLANK)
  {
   ar1Len=FindEmpty(pos,y1,ar1);
   ar2Len=FindEmpty(x2,y2,ar2);
   if(IsShare(ar1,ar1Len,ar2,ar2Len))
    return true;
   pos++;
  }
// }
 //如果非上下非左右,即构成矩形的关系
 return false;
}
bool IsLink(int x1,int y1,int x2,int y2)
{
 if(IsDirectLink(x1,y1,x2,y2))
 {
  printf("DirectLink!");
  return true;
 }
 else
 {
  //arr1Len=FindEmpty(x1,y1,arr1);
  //arr2Len=FindEmpty(x2,y2,arr2);
  if(IsShare(arr1,arr1Len,arr2,arr2Len))
  {
   printf("One Corner Link!");
   return true;
  }
  else
  {
   printf("Two Corner Link!");
   return IndirectLink(x1,y1,x2,y2);
  }
 }
}
int main(int argc, char* argv[])
{
 int xpos1,ypos1,xpos2,ypos2;
 printf("请输入要测试的行列(按数据结构中的数组序):");
 scanf("%d %d %d %d",&xpos1,&ypos1,&xpos2,&ypos2);
 InitArray();
 arr1Len=FindEmpty(xpos1,ypos1,arr1);
 arr2Len=FindEmpty(xpos2,ypos2,arr2);
  /*
 if(IsShare(arr1,arr1Len,arr2,arr2Len))
  printf("有交点/n");
 else
  printf("没有交点/n");
 //ShowArray(arr1,arr1Len);
 */
 if(IsLink(xpos1,ypos1,xpos2,ypos2))
  printf("有交点/n");
 else
  printf("没有交点/n");
 
 return 0;
}

原创粉丝点击