package zx.z2014825.ff;
import java.util.ArrayList;
public class functions {
public static int count;
public static int che[][]=new int[15][15];
public static int us[][];
public static int enemy[][];
public static ArrayList<eventers> firstSearch=new ArrayList<eventers>();
public static int judgement(int x,int y){
int result=0;
int heng=counter(3,x,y)+counter(7,x,y);
int zong=counter(1,x,y)+counter(5,x,y);
int pie=counter(2,x,y)+counter(6,x,y);
int na= counter(8,x,y)+counter(4,x,y);
//
if(interfacer.chess[x][y]==1){
result=Math.max(Math.max(Math.max(heng-1, zong-1),pie-1 ), na-1);
return result;
}else if(interfacer.chess[x][y]==-1){
result=Math.min(Math.min(Math.min(heng+1, zong+1),pie+1 ),na+1 );
return result;
}
return -10;
}
public static zuobiao nextzb(int x,int y){
/*************************防守*****************************/
/*
* 防守就是检查有没有可挽回的必死或者即将不可挽回的必死局面
* 一旦出现可挽回必死局面,则跳过进攻,直接开堵
* 可挽回的必死的局面包括:
* 1、三个连续的子且两头没堵
* 2、四个连续的子只赌了一头
* 3、连续的两个子两头没堵+一个两子连线上一子两头没堵(相差仅限一格)
* 即将不可挽回的局面用算法解决,其结果包括差两子和差一子两种情况。
* 1、如果是差两子的情况,可先检查进攻算法,如果己方有差两子以内就可以结束,则不管防守
* 2、如果是差一子的情况,优先防守
*/
//进入一级搜索
// for(int i=0;i<15;i++){
// for(int j=0;j<15;j++){
// System.out.print(che[i][j]+"\0");
// }
// System.out.println();
// }
// FSearch(x,y);
// System.out.println("+++++++++++++++++++++++++++++++");
// for(int i=0;i<15;i++){
// for(int j=0;j<15;j++){
// System.out.print(interfacer.chess[i][j]+"\0");
// }
// System.out.println();
// }
// System.out.println("+++++++++++++++++++++++++++++++");
setValue();
// zuobiao zbF=DFSearch();
// for(int i=0;i<15;i++){
// for(int j=0;j<15;j++){
// System.out.print(enemy[i][j]+"\0");
// }
// System.out.println();
// }
// System.out.println("******************************");
// for(int i=0;i<15;i++){
// for(int j=0;j<15;j++){
// System.out.print(us[i][j]+"\0");
// }
// System.out.println();
// }
// System.out.println("******************************");
// for(int i=0;i<15;i++){
// for(int j=0;j<15;j++){
// if(i>0){
// if(interfacer.chess[i-1][j]==-1){
// System.out.println("找到了,在x="+i+"y="+j+"处,setNum="+setNum(1,i-1,j)+"counter="+counter(1,i-1,j)+"b="+isBlock(1,i-1,j));
// }
// }
// }
// }
zuobiao zbF=new zuobiao(-1,-1);
zuobiao zbF1=new zuobiao(-1,-1);
zuobiao zbF2=new zuobiao(-1,-1);
for(int i=0;i<15;i++){
for(int j=0;j<15;j++){
if(zbF1.getX()==-1&&zbF1.getY()==-1){
if(enemy[i][j]>1){
zbF1.setX(i);
zbF1.setY(j);
}
}else{
if(enemy[i][j]>enemy[zbF1.getX()][zbF1.getY()]){
zbF1.setX(i);
zbF1.setY(j);
}
}
}
}
for(int i=0;i<15;i++){
for(int j=0;j<15;j++){
if(zbF2.getX()==-1&&zbF2.getY()==-1){
if(us[i][j]>1){
zbF2.setX(i);
zbF2.setY(j);
}
}else{
if(us[i][j]>us[zbF2.getX()][zbF2.getY()]){
zbF2.setX(i);
zbF2.setY(j);
}
}
}
}
if(zbF1.getX()>-1&&zbF1.getY()>-1&&zbF2.getX()>-1&&zbF2.getY()>-1){
System.out.println("***"+enemy[zbF1.getX()][zbF1.getY()]+"+++"+enemy[zbF2.getX()][zbF2.getY()]);
if(enemy[zbF1.getX()][zbF1.getY()]>=enemy[zbF2.getX()][zbF2.getY()]){
zbF=zbF1;
}else {
zbF=zbF2;
}
}
//进入二级搜索(预搜索)
/*************************进攻******************************/
//zuobiao zx=new zuobiao(0,0);
return zbF;
}
public static void setValue(){
us=new int[15][15];
enemy=new int[15][15];
int counter11=1;
int counter12=1;
int counter13=1;
int counter14=1;
int counter15=1;
int counter16=1;
int counter17=1;
int counter18=1;
int counter21=1;
int counter22=1;
int counter23=1;
int counter24=1;
int counter25=1;
int counter26=1;
int counter27=1;
int counter28=1;
for(int i=0;i<15;i++){
for(int j=0;j<15;j++){
us[i][j]=1;
}
}
for(int i=0;i<15;i++){
for(int j=0;j<15;j++){
us[i][j]=1;
}
}
/************************************/
// System.out.println("+++++++++++++++++++++++++++++++");
for(int i=0;i<15;i++){
for(int j=0;j<15;j++){
if(interfacer.chess[i][j]==0){
if(i>0&&interfacer.chess[i-1][j]==actionListener.putting){
//System.out.println();
counter11=setNum(1,i-1,j);
//System.out.println(counter11+"**");
}
if(i>0&&j<14&&interfacer.chess[i-1][j+1]==actionListener.putting){
counter12=setNum(2,i-1,j+1);
}
if(j<14&&interfacer.chess[i][j+1]==actionListener.putting){
counter13=setNum(3,i,j+1);
}
if(i<14&&j<14&&interfacer.chess[i+1][j+1]==actionListener.putting){
counter14=setNum(4,i+1,j+1);
}
if(i<14&&interfacer.chess[i+1][j]==actionListener.putting){
counter15=setNum(5,i+1,j);
}
if(i<14&&j>0&&interfacer.chess[i+1][j-1]==actionListener.putting){
counter16=setNum(6,i+1,j-1);
}
if(j>0&&interfacer.chess[i][j-1]==actionListener.putting){
counter17=setNum(7,i,j-1);
}
if(i>0&&j>0&&interfacer.chess[i-1][j-1]==actionListener.putting){
counter18=setNum(8,i-1,j-1);
}
}
us[i][j]=counter11*counter12*counter13*counter14*counter15*counter16*counter17*counter18;
counter11=1;
counter12=1;
counter13=1;
counter14=1;
counter15=1;
counter16=1;
counter17=1;
counter18=1;
// System.out.print(us[i][j]+"\0");
}
// System.out.println();
}
// System.out.println("+++++++++++++++++++++++++++++++"+actionListener.putting);
/*****************************/
for(int i=0;i<15;i++){
for(int j=0;j<15;j++){
if(interfacer.chess[i][j]==0){
if(i>0&&interfacer.chess[i-1][j]==changeA(actionListener.putting)){
counter21=setNum(1,i-1,j);
}
if(i>0&&j<14&&interfacer.chess[i-1][j+1]==changeA(actionListener.putting)){
counter22=setNum(2,i-1,j+1);
}
if(j<14&&interfacer.chess[i][j+1]==changeA(actionListener.putting)){
counter23=setNum(3,i,j+1);
}
if(i<14&&j<14&&interfacer.chess[i+1][j+1]==changeA(actionListener.putting)){
counter24=setNum(4,i+1,j+1);
}
if(i<14&&interfacer.chess[i+1][j]==changeA(actionListener.putting)){
counter25=setNum(5,i+1,j);
}
if(i<14&&j>0&&interfacer.chess[i+1][j-1]==changeA(actionListener.putting)){
counter26=setNum(6,i+1,j-1);
}
if(j>0&&interfacer.chess[i][j-1]==changeA(actionListener.putting)){
counter27=setNum(7,i,j-1);
}
if(i>0&&j>0&&interfacer.chess[i-1][j-1]==changeA(actionListener.putting)){
counter28=setNum(8,i-1,j-1);
}
}
enemy[i][j]=counter21*counter22*counter23*counter24*counter25*counter26*counter27*counter28;
counter21=1;
counter22=1;
counter23=1;
counter24=1;
counter25=1;
counter26=1;
counter27=1;
counter28=1;
}
}
}
public static int setNum(int direction ,int x,int y){
int a=Math.abs(counter(direction, x, y));
boolean b=isBlock(direction ,x,y);
if(a==1&&b==false){
return 3;
}else if(a==1&&b==true){
return 2;
}else if(a==2&&b==false){
return 30;
}else if(a==2&&b==true){
return 5;
}else if(a==3&&b==false){
return 1000;
}else if(a==3&&b==true){
return 30;
}else if(a==4&&b==false){
return 10000;
}else if(a==4&&b==true){
return 10000;
}
return 1;
}
public static int changeA(int a){
if(a==1){
return -1;
}else if(a==-1){
return 1;
}
return 0;
}
public static zuobiao DFSearch(){
// che[][]=new int[15][15];
评论0