简易五子棋_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > 简易五子棋

简易五子棋

 2014/7/25 18:42:46  GeassG  程序员俱乐部  我要评论(0)
  • 摘要:以下是我做的简易的五子棋,可进行人机互动哦==。这里主要包括界面的制作与显示,还包括判断输赢。publicclassWzqextendsJFrame{/**定义一个五子棋类*/privateintflat;//判断输赢的标志publicstaticvoidmain(String[]args){//实例化一个类Wzqwzq=newWzq();wzq.showFrame();}privatevoidshowFrame(){//设置程序的名字this.setTitle("五子棋")
  • 标签:

以下是我做的简易的五子棋,可进行人机互动哦= =。

?

这里主要包括界面的制作与显示,还包括判断输赢。

class="java" name="code">public class Wzq extends JFrame{
	/*
	 * 定义一个五子棋类
	 */
	private int flat ;//判断输赢的标志

	public static void main(String[] args) {
		//实例化一个类
		Wzq wzq = new Wzq();
		wzq.showFrame();
		
	}
	 
	private void showFrame(){
		
		//设置程序的名字
	    this.setTitle("五子棋");

		//设置大小
	    this.setSize(650, 650);
		//在屏幕中间显示
	    this.setLocationRelativeTo(null);
		//设置窗口的关闭
	    this.setDefaultCloseOperation(3);
		//设置窗口的大小无法调整
	    this.setResizable(false);
	   
	    //添加背景
	    background();
	    this.setLayout(null);
	    
	    //创建菜单栏
	    JMenuBar JMB = creatJMenuBar();
	    //设置菜单栏的位置
	    JMB.setBounds(0,0,650,30);
	    //添加菜单栏
	    this.add(JMB);
	    //添加悔棋按钮
	    JButton Btn_return = new JButton("悔棋");
	    //添加新的的一局按钮
	    JButton Btn_new = new JButton("新的一局");
	    //添加人人对战按钮
	    JButton Btn_PvP = new JButton("玩家之间对战");
	    //添加人机对战按钮
	    JButton Btn_PvC = new JButton("玩家与电脑对战");
	    //设置按钮的大小和方位
	    Btn_return.setBounds(100,520, 100, 40);
	    Btn_new.setBounds(100,570,100,40);
	    Btn_PvP.setBounds(300, 520, 200, 40);
	    Btn_PvC.setBounds(300, 570, 200, 40);
	    //把按钮添加在面板上
	    this.add(Btn_return);
	    this.add(Btn_new);
	    this.add(Btn_PvP);
	    this.add(Btn_PvC);
	    //创建按钮的事件处理类
	    MyActionListener MAL = new MyActionListener(this);
	    //添加监听器
	    Btn_return.addActionListener(MAL);
		Btn_new.addActionListener(MAL);
		Btn_PvP.addActionListener(MAL);
		Btn_PvC.addActionListener(MAL);
	    //窗口显示
	    this.setVisible(true);
		//创建事件处理类
	    MyMouseListener MML = new MyMouseListener(this);
	    //添加监听器
	    this.addMouseListener(MML);
		

	}
	
	//
	private JMenuBar creatJMenuBar() {
		JMenuBar JMB = new JMenuBar();
		
		String [] arrayMenu = {"游戏","帮助"};
		
		String [][] arrayItem = {{"玩家之间的对战","玩家与电脑对战","悔棋","清空棋盘"},{"查看帮助","关于Chess"}};
		
		//遍历arrayMenu数组
		for(int i=0;i<arrayMenu.length;i++)
		{
			JMenu Menu = new JMenu(arrayMenu[i]);
			for(int j=0;j<arrayItem[i].length;j++)
			{
				JMenuItem item = new JMenuItem(arrayItem[i][j]);
				Menu.add(item);
			}
			JMB.add(Menu);
		}
		
		return JMB;
	}

	//重绘
	public void paint(Graphics g)
	{
		super.paint(g);
		//重绘棋盘
		ChessBoard(g);
		//判断输赢的依据归0
		flat = 0;
		//重绘棋子
		for(int i=0;i<Data.XYList.size();i++)
		{
			ChessmanCoordinate CC = Data.XYList.get(i);
			
			//将X,Y经过处理得到棋盘二维数组上的坐标
			int List_X = (int)(CC.X_Chessman-Data.X_Board)/Data.Width_Board;
			int List_Y = (int)(CC.Y_Chessman-Data.Y_Board)/Data.Width_Board;
			if(i%2==0)
			{
				g.setColor(Color.black);
				Data.Chess[List_X][List_Y]=1;
				g.fillOval(CC.X_Chessman-Data.Radius/2, CC.Y_Chessman-Data.Radius/2, Data.Radius, Data.Radius);
			}
			else{
				g.setColor(Color.white);
				Data.Chess[List_X][List_Y]=-1;
				g.fillOval(CC.X_Chessman-Data.Radius/2, CC.Y_Chessman-Data.Radius/2, Data.Radius, Data.Radius);
				
			}
			
		}
		
		//判断输赢
		Judge_winner();
		
    }
	
	
	/**
	 * 判断输赢的方法
	 */
	public void Judge_winner(){
		for(int i=0;i<Data.X_number;i++){
			for(int j=0;j<Data.Y_number;j++){
				if(Data.Chess[i][j]==1){
						if((j+4)<Data.X_number&&Data.Chess[i][j+4]==1){
							if(Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==1){
								flat = 1;
								break;
							}
							
						}
						else if((i+4)<Data.X_number&&Data.Chess[i+4][j]==1){
							if(Data.Chess[i+3][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+1][j]==1){
								flat = 1;
								break;
							}
							
						}
						else if((i+4)<Data.X_number&&(j+4)<Data.X_number&&Data.Chess[i+4][j+4]==1){
							if(Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==1){
								flat = 1;
								break;
							}
							
						}
						else if((i+4)<Data.X_number&&(j-4)>=0&&Data.Chess[i+4][j-4]==1){
							if(Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==1&&Data.Chess[i+3][j-3]==1){
								flat = 1;
								break;
							}
							
						}																														
					}
				else if(Data.Chess[i][j]==-1){
						if((j+4)<Data.X_number&&Data.Chess[i][j+4]==-1){
							if(Data.Chess[i][j+1]==-1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==-1){
								flat = -1;
							    break;	
							    }
						}
						else if((i+4)<Data.X_number&&Data.Chess[i+4][j]==-1){
							if(Data.Chess[i+3][j]==-1&&Data.Chess[i+2][j]==-1&&Data.Chess[i+1][j]==-1){
								flat = -1;
								break;	
								}
						
					    }
						else if((i+4)<Data.X_number&&(j+4)<Data.X_number&&Data.Chess[i+4][j+4]==-1){
							if(Data.Chess[i+1][j+1]==-1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==-1){
								flat = -1;
								break;	
								}
						
					    }
					    else if((i+4)<Data.X_number&&(j-4)>=0&&Data.Chess[i+4][j-4]==-1){
					    	if(Data.Chess[i+1][j-1]==-1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==-1){
					    		flat = -1;
					    		break;
					    		}
						}																																				
				}					
		    }
		   if(flat == 1){
			   System.out.println("黑棋赢");
			   break;
		   }
		   else if(flat == -1){
			   System.out.println("白棋赢");
			   break;
		   }
		}	
	}
	
	/**
	 *创建一个构造棋盘的方法
	 */
	public void ChessBoard(Graphics g){
		//通过两个循环来构造棋盘

		for(int i=0;i<Data.X_number;i++)
		{
			g.drawLine(Data.X_Board, Data.Y_Board+i*Data.Width_Board, Data.X_Board+Data.Width_Board*(Data.Y_number-1), Data.Y_Board+i*Data.Width_Board);
		}
		for(int j=0;j<Data.Y_number;j++)
		{
			g.drawLine(Data.X_Board+j*Data.Width_Board, Data.Y_Board, Data.X_Board+j*Data.Width_Board, Data.Y_Board+Data.Width_Board*(Data.X_number-1));
		}
		
		
	}
	
	/**
	 * 创造一个设置背景的方法
	 */
	public void background(){
		//实例化一个ImageIcon对象
		ImageIcon image = new ImageIcon("image/background.jpg");
		//实例化一个JLabel对象
		JLabel  JLB = new JLabel(image);
		//设置标签的大小的起始位置
		JLB.setBounds(0, 0,this.getWidth(),this.getHeight());
		//获取窗体上LayoutComponent面板对象,向该面板添加一个标签,同时制定该标签显示在该面板的最上层
		this.getLayeredPane().add(JLB, new Integer(Integer.MIN_VALUE));
		//获取LayeredPanel面板上的另一层面板对象ContentPanel
		JPanel contentPanel = (JPanel)this.getContentPane();
		//设置contentPanel面板为透明
		contentPanel.setOpaque(false);
	}
	
}

?这里是保存棋子坐标的类

//用于保存棋子的坐标的类
public class ChessmanCoordinate {
	public int X_Chessman;
	public int Y_Chessman;
}

?这是一个保存数据的地方。

public class Data {
	//设置棋盘的起点位置
	public static final int X_Board=100;
	public static final int Y_Board=70;
	
	//设置棋盘中格子的宽度
	public static final int Width_Board = 33;
	
	//设置棋盘中横线的数目
	public static final int X_number = 15;
	//设置棋盘中纵线的数目
	public static final int Y_number = 15;
	
	//设置棋盘线条宽度
	public static final int lineWidth = 1;
	
	//设置棋子的半径
	public static final int Radius = 30;
	
	//保存棋子的坐标
	public static List<ChessmanCoordinate> XYList = new ArrayList<ChessmanCoordinate>();
	
	//标志制定位子上的值
	public static final int [][] Chess = new int[X_number][Y_number];
	
	//保存棋盘上的状况
	public static final int [][] Value = new int[X_number][Y_number];
	
	//防守权值设置
	public static final int Value_1 = 2;
	public static final int Value_Life_2 = 60;
	public static final int Value_Dead_2 = 10;
	public static final int Value_Life_3 = 800;
	public static final int Value_Dead_3 = 50;
	public static final int Value_4 = 3000;
	public static final int Value_Galton = 90;
	
	//进攻权值设置
	public static final int Attack_Value_2 = 55;
	public static final int Attack_Value_3 = 150;
	public static final int Attack_Value_4 = 900;
	public static final int Attack_Value_5 = 10000;
	
	//输出权值表的方法
	public static void print(){
		for(int i=0;i<Data.X_number;i++){
			for(int j=0;j<Data.Y_number;j++){
				System.out.print(Value[j][i]+"\t");
			}
		System.out.println();
		}
		System.out.println();
	}
	
}

?这里是按钮监听器,负责对按钮功能的实现。

public class MyActionListener implements ActionListener{

	//扩大参数适用范围
	private JFrame JF;
	public static int Choose_P_or_C=0;

	public MyActionListener(JFrame JF) {
		this.JF = JF;
		
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO 自动生成的方法存根
		if(arg0.getActionCommand().equals("新的一局")){
			int ChessNumber = Data.XYList.size();
			for(int i=0;i<ChessNumber;i++){
				
                ChessmanCoordinate CC1 = Data.XYList.get(Data.XYList.size()-1);
				
				//将X,Y经过处理得到棋盘二维数组上的坐标
				int List_X1 = (CC1.X_Chessman-Data.X_Board)/Data.Width_Board;
				int List_Y1 = (CC1.Y_Chessman-Data.Y_Board)/Data.Width_Board;
				
				Data.Chess[List_X1][List_Y1]=0;
				
				
				Data.XYList.remove(Data.XYList.size()-1);
			
				
			}

			
		}else if(arg0.getActionCommand().equals("悔棋")){
			if(Data.XYList.size()!=0){
				
	            ChessmanCoordinate CC1 = Data.XYList.get(Data.XYList.size()-1);
				
				//将X,Y经过处理得到棋盘二维数组上的坐标
				int List_X1 = (CC1.X_Chessman-Data.X_Board)/Data.Width_Board;
				int List_Y1 = (CC1.Y_Chessman-Data.Y_Board)/Data.Width_Board;
				
				Data.Chess[List_X1][List_Y1]=0;
				
				
				Data.XYList.remove(Data.XYList.size()-1);

			}
			
			
		}else if(arg0.getActionCommand().equals("玩家之间对战")){
			//先清空棋盘
			int ChessNumber = Data.XYList.size();
			for(int i=0;i<ChessNumber;i++){
				
                ChessmanCoordinate CC1 = Data.XYList.get(Data.XYList.size()-1);
				
				//将X,Y经过处理得到棋盘二维数组上的坐标
				int List_X1 = (CC1.X_Chessman-Data.X_Board)/Data.Width_Board;
				int List_Y1 = (CC1.Y_Chessman-Data.Y_Board)/Data.Width_Board;
				
				Data.Chess[List_X1][List_Y1]=0;
				
				
				Data.XYList.remove(Data.XYList.size()-1);
			
				
			}
			Choose_P_or_C= 1;
			
			
			
		}else if(arg0.getActionCommand().equals("玩家与电脑对战")){
			//先清空棋盘
			int ChessNumber = Data.XYList.size();
			for(int i=0;i<ChessNumber;i++){
				
                ChessmanCoordinate CC1 = Data.XYList.get(Data.XYList.size()-1);
				
				//将X,Y经过处理得到棋盘二维数组上的坐标
				int List_X1 = (CC1.X_Chessman-Data.X_Board)/Data.Width_Board;
				int List_Y1 = (CC1.Y_Chessman-Data.Y_Board)/Data.Width_Board;
				
				Data.Chess[List_X1][List_Y1]=0;
				
				
				Data.XYList.remove(Data.XYList.size()-1);
			
				
			}
			Choose_P_or_C=2;
			
		}
		//调用重绘的方法
		JF.repaint();
		
	}

?这里是人机对战时机器的分析过程。其实如果我学过一些算法的话应该可以优化一下,至少不会那么长= =

public class MyMouseListener implements MouseListener{

	//扩大参数适用范围
	private JFrame JF;
	private int WhetherAdd;
	private int Pre_BestValue_X;
	private int Pre_BestValue_Y;

	
	public MyMouseListener(JFrame JF){
		this.JF = JF;
		
		
	}
	
	@Override
	public void mouseClicked(MouseEvent arg0) {
		// TODO 自动生成的方法存根
		
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO 自动生成的方法存根
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO 自动生成的方法存根
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO 自动生成的方法存根
		int X_Chessman = arg0.getX();
		int Y_Chessman = arg0.getY();
		WhetherAdd =0;
		if(X_Chessman>=Data.X_Board&&X_Chessman<=Data.X_Board+(Data.Y_number-1)*Data.Width_Board&&Y_Chessman>=Data.Y_Board&&Y_Chessman<=Data.Y_Board+(Data.X_number-1)*Data.Width_Board)
		{
			//对坐标进行处理,保证在交叉点上
			int quotient_X = (X_Chessman-Data.X_Board)/Data.Width_Board;
			int quotient_Y = (Y_Chessman-Data.Y_Board)/Data.Width_Board;
			float remainder_X = (X_Chessman-Data.X_Board)%Data.Width_Board;
			float remainder_Y = (Y_Chessman-Data.Y_Board)%Data.Width_Board;
			if(remainder_X<Data.Width_Board/2){
				X_Chessman = Data.X_Board+quotient_X*Data.Width_Board;
			}
			else{
				X_Chessman = Data.X_Board+(quotient_X+1)*Data.Width_Board;
			}
			if(remainder_Y<Data.Width_Board/2){
				Y_Chessman = Data.Y_Board+quotient_Y*Data.Width_Board;
			}
			else{
				Y_Chessman = Data.Y_Board+(quotient_Y+1)*Data.Width_Board;
			}
			if(MyActionListener.Choose_P_or_C==1){
				//人人对战
				PvP(X_Chessman,Y_Chessman);
			}else if(MyActionListener.Choose_P_or_C==2)
				//人机对战
				PvC(X_Chessman,Y_Chessman);
		
		}
		
		//调用重绘
		JF.repaint();

		
	}
	
	//人人对战的方法
	public void PvP(int X_Chessman,int Y_Chessman){
		//实例化一个ChessmanCoordinate对象,当点在棋盘上且不覆盖给的点的情况下才输入数据
		if(Data.XYList.size()==0)
		{
			ChessmanCoordinate CC1 = new ChessmanCoordinate();
			CC1.X_Chessman = X_Chessman;
			CC1.Y_Chessman = Y_Chessman;
				
			//添加到队列中
			Data.XYList.add(CC1);
			
			
		}
		else
		{
			for(int i=0;i<Data.XYList.size();i++)
			{
				ChessmanCoordinate CCC1 = Data.XYList.get(i);
				if(CCC1.X_Chessman==X_Chessman&&CCC1.Y_Chessman==Y_Chessman)
				{
					break;
				}
				else if(i==Data.XYList.size()-1)
				{
					ChessmanCoordinate CC1 = new ChessmanCoordinate();
					CC1.X_Chessman = X_Chessman;
					CC1.Y_Chessman = Y_Chessman;
						
					//添加到队列中
					Data.XYList.add(CC1);
					
					//调用重绘
					JF.repaint();
				
				}
					
				
			}
											
		}
		
	}
	
	//人机对战的方法
	public void PvC(int X_Chessman,int Y_Chessman){
		
		//清空权值表
		ReFresh_Value();
		
		//实例化一个ChessmanCoordinate对象,当点在棋盘上且不覆盖给的点的情况下才输入数据
		
		if(Data.XYList.size()==0)
		{
			ChessmanCoordinate CC1 = new ChessmanCoordinate();
			CC1.X_Chessman = X_Chessman;
			CC1.Y_Chessman = Y_Chessman;
///////////////////////////////////////////////////////////////////////////////////////////////////
			int List_X = (int)(CC1.X_Chessman-Data.X_Board)/Data.Width_Board;
			int List_Y = (int)(CC1.Y_Chessman-Data.Y_Board)/Data.Width_Board;
			
			Data.Chess[List_X][List_Y]=1;
///////////////////////////////////////////////////////////////////////////////////////////////////

			//添加到队列中
			Data.XYList.add(CC1);
			
			//调用重绘
			JF.repaint();
			
			//获取棋盘上的状况
			Get_Station();	
			
		}
		else
		{
			for(int i=0;i<Data.XYList.size();i++)
			{
				ChessmanCoordinate CCC1 = Data.XYList.get(i);
				if(CCC1.X_Chessman==X_Chessman&&CCC1.Y_Chessman==Y_Chessman)
				{
					return;
				}
				else if(i==Data.XYList.size()-1)
				{
					WhetherAdd = 1;
				
				}
					
				
			}
			if(WhetherAdd == 1){
				ChessmanCoordinate CC1 = new ChessmanCoordinate();
				CC1.X_Chessman = X_Chessman;
				CC1.Y_Chessman = Y_Chessman;

                int List_X = (int)(CC1.X_Chessman-Data.X_Board)/Data.Width_Board;
                int List_Y = (int)(CC1.Y_Chessman-Data.Y_Board)/Data.Width_Board;

                Data.Chess[List_X][List_Y]=1;

					
				//添加到队列中
				Data.XYList.add(CC1);
				
				//调用重绘
				JF.repaint();
				
				//获取棋盘上的状况
				Get_Station();
				
			}
											
		}

		//输出权值表
		Data.print();
		
		//寻找权值最高点
		int BestValue_X = 0;
		int BestValue_Y = 0;
		int Best = 0;
		for(int i=0;i<Data.X_number;i++){
			for(int j=0;j<Data.Y_number;j++){
				if(Data.Value[i][j]>Best){
					Best = Data.Value[i][j];
					BestValue_X = i;
					BestValue_Y = j;
				}
			}
		}
		
		/*
		 * 预判的过程
		 */
		Pre_BestValue_X = 0;
		Pre_BestValue_Y = 0;
		if(Best<310){
			Pre_Judge();
			if(Data.Value[Pre_BestValue_X][Pre_BestValue_Y]>=900){
				BestValue_X = Pre_BestValue_X;
				BestValue_Y = Pre_BestValue_Y;
			}
		}
		System.out.println("Pre_BestValue_X = "+Pre_BestValue_X+"Pre_BestValue_Y = "+Pre_BestValue_Y);
		
		
		ChessmanCoordinate CC2 = new ChessmanCoordinate();
		CC2.X_Chessman = BestValue_X*Data.Width_Board+Data.X_Board;
		CC2.Y_Chessman = BestValue_Y*Data.Width_Board+Data.Y_Board;


        Data.Chess[BestValue_X][BestValue_Y]=-1;
        Data.Value[BestValue_X][BestValue_Y]=0;

		//添加到队列中
		Data.XYList.add(CC2);
		
		//调用重绘
		JF.repaint();
				
		
	}
	
	/**
	 * 构建预判的方法
	 */
	public void Pre_Judge(){
		int Pre_Best=0;
		int Chang1_X,Chang1_Y;
		for(int j=0;j<Data.X_number;j++){
			for(int i=0;i<Data.Y_number;i++){
				if(Data.Chess[i][j]==0){
					Data.Chess[i][j]=1;
					Chang1_X = i;
					Chang1_Y = j;
					Get_Station();
					for(int m=0;m<Data.X_number;m++){
						for(int n=0;n<Data.Y_number;n++){
							if(Data.Value[n][m]>Pre_Best){
								Pre_Best = Data.Value[n][m];
								Pre_BestValue_X = i;
								Pre_BestValue_Y = j;
							}
						}
					}
					Data.Chess[i][j]=0;
				}
			}
		}
	}
	
	/**
	 * 获取棋盘上的状况的方法
	 */
	public  void  Get_Station(){
		
        
		for(int j=0;j<Data.X_number;j++){
			for(int i=0;i<Data.Y_number;i++){
				if(Data.Chess[i][j]==0){
					
					
					//单棋子判断的方法	
					
					Defence_one(i,j);
					
					//双棋子判断的方法	
					
					Defence_two(i,j);
					
					//三棋子判断的方法	
					
					Defence_three(i,j);
					
					//四棋子判断的方法
					
					Defence_four(i,j);
					
					
					/*
					 * 梅花阵判断
					 */
					if((i+2)<Data.X_number&&(j+2)<Data.Y_number&&(i-2)>=0&&(j-2)>=0){
						if(Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]!=-1&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]!=-1&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]!=-1&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]!=-1){
							Data.Value[i][j]=Data.Value[i][j]+Data.Value_Galton;
						}
						if(Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]!=-1&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]!=-1&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]!=-1&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-1][j+1]!=-1){
							Data.Value[i][j]=Data.Value[i][j]+Data.Value_Galton;
						}
						
					}
				}
			}
		}
		
		
		/*
		 * 进攻部分
		 */
		
		for(int j=0;j<Data.X_number;j++){
			for(int i=0;i<Data.Y_number;i++){
				if(Data.Chess[i][j]==0){
					
					//形成2棋子的方法
					
					Attack_two(i,j);

					//形成3棋子的方法
					 
					Attack_three(i,j);
					
					//形成4棋子的方法
					
					Attack_four(i,j);
					
					//形成5棋子的方法
					
					Attack_five(i,j);
					
				}
			}
		}
	}
	
	/*
	 * 构建单棋子判断的方法(防守)
	 */
	public void Defence_one(int i,int j){
		if((j+1)<Data.X_number&&Data.Chess[i][j+1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_1;
		}
		if((i+1)<Data.X_number&&(j+1)<Data.X_number&&Data.Chess[i+1][j+1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_1;
		}
		if((i-1)>=0&&(j+1)<Data.X_number&&Data.Chess[i-1][j+1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_1;
		}
		if((i+1)<Data.X_number&&Data.Chess[i+1][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_1;
		}
		if((i-1)>=0&&Data.Chess[i-1][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_1;
		}
		if((i+1)<Data.X_number&&(j-1)>=0&&Data.Chess[i+1][j-1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_1;
		}
		if((i-1)>=0&&(j-1)>=0&&Data.Chess[i-1][j-1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_1;
		}
		if((j-1)>=0&&Data.Chess[i][j-1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_1;
		}
	}
	
	/*
	 * 构建双棋子判断的方法(防守)
	 */
	public void Defence_two(int i,int j){
		/*
		 * 双棋子横向判断
		 */
		
		//横二连活  
		if((i+3)<Data.X_number&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+3][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_2;
		}
		//横二连死   
		if((i+3)<Data.X_number&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+3][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_2;
		}
		//横二连活  
		if((i-3)>=0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1&&Data.Chess[i-3][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_2;
		}
		//横二连死   
		if((i-3)>=0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1&&Data.Chess[i-3][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_2;
		}
		
		/*
		 * 双棋子纵向判断
		 */
		
		//纵二连活   
		if((j+3)<Data.X_number&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_2;
		}
		//纵二连死   
		if((j+3)<Data.X_number&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_2;
		}
		//纵二连活   
		if((j-3)>=0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1&&Data.Chess[i][j-3]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_2;
		}
		//纵二连死   
		if((j-3)>=0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1&&Data.Chess[i][j-3]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_2;
		}
		
		/*
		 * 双棋子斜向判断
		 */
		
		//斜二连活  
		if((i+3)<Data.X_number&&(j+3)<Data.X_number&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_2;
		}
		//斜二连死   
		if((i+3)<Data.X_number&&(j+3)<Data.X_number&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_2;
		}
		//斜二连活  
		if((i-3)>=0&&(j-3)>=0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1&&Data.Chess[i-3][j-3]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_2;
		}
		//斜二连死   
		if((i-3)>=0&&(j-3)>=0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1&&Data.Chess[i-3][j-3]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_2;
		}
		//斜二连活  
		if((i-3)>=0&&(j+3)<Data.X_number&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==1&&Data.Chess[i-3][j+3]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_2;
		}
		//斜二连死   
		if((i-3)>=0&&(j+3)<Data.X_number&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==1&&Data.Chess[i-3][j+3]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_2;
		}
		//斜二连活  
		if((i+3)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==1&&Data.Chess[i+3][j-3]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_2;
		}
		//斜二连死   
		if((i+3)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==1&&Data.Chess[i+3][j-3]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_2;
		}
	}
	
	
	/*
	 * 构建三棋子判断的方法(防守)
	 */
	
	public void Defence_three(int i,int j){
		/*
		 * 三棋子横向判断
		 */
		
		//横三连活  
		if((i+4)<Data.X_number&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+3][j]==1&&Data.Chess[i+4][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//横三连死   
		if((i+4)<Data.X_number&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+3][j]==1&&Data.Chess[i+4][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//横三连活  
		if((i-4)>=0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1&&Data.Chess[i-3][j]==1&&Data.Chess[i-4][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//横三连死   
		if((i-4)>=0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1&&Data.Chess[i-3][j]==1&&Data.Chess[i-4][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		
		
		//横2-1连活
		if((i+3)<Data.X_number&&(i-2)>=0&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+3][j]==0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//横1-2连活
		if((i+2)<Data.X_number&&(i-3)>=0&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==0&&Data.Chess[i-3][j]==0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//横2-1连死
		if((i+3)<Data.X_number&&(i-2)>=0&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+3][j]==-1&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//横2-1连死
		if((i+3)<Data.X_number&&(i-2)>=0&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+3][j]==0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//横1-2连死
		if((i+2)<Data.X_number&&(i-3)>=0&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==-1&&Data.Chess[i-3][j]==0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//横1-2连死
		if((i+2)<Data.X_number&&(i-3)>=0&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==0&&Data.Chess[i-3][j]==-1&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		
		
		
		/*
		 * 三棋子纵向判断
		 */
		
		//纵三连活   
		if((j+4)<Data.X_number&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==1&&Data.Chess[i][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//纵三连死   
		if((j+4)<Data.X_number&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==1&&Data.Chess[i][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//纵三连活   
		if((j-4)>=0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1&&Data.Chess[i][j-3]==1&&Data.Chess[i][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//纵三连死   
		if((j-4)>=0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1&&Data.Chess[i][j-3]==1&&Data.Chess[i][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		
		//纵2-1连活
		if((j+3)<Data.X_number&&(j-2)>=0&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//纵1-2连活
		if((j+2)<Data.X_number&&(j-3)>=0&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==0&&Data.Chess[i][j-3]==0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//纵2-1连死
		if((j+3)<Data.X_number&&(j-2)>=0&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==-1&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//纵2-1连死
		if((j+3)<Data.X_number&&(j-2)>=0&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//纵1-2连死
		if((j+2)<Data.X_number&&(j-3)>=0&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j-3]==0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//纵1-2连死
		if((j+2)<Data.X_number&&(j-3)>=0&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==0&&Data.Chess[i][j-3]==-1&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		
		/*
		 * 三棋子斜向判断
		 */
		
		//斜三连活  
		if((i+4)<Data.X_number&&(j+4)<Data.X_number&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==1&&Data.Chess[i+4][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//斜三连死   
		if((i+4)<Data.X_number&&(j+4)<Data.X_number&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==1&&Data.Chess[i+4][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//斜三连活  
		if((i-4)>=0&&(j-4)>=0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1&&Data.Chess[i-3][j-3]==1&&Data.Chess[i-4][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//斜三连死   
		if((i-4)>=0&&(j-4)>=0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1&&Data.Chess[i-3][j-3]==1&&Data.Chess[i-4][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//斜三连活  
		if((i-4)>=0&&(j+4)<Data.X_number&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==1&&Data.Chess[i-3][j+3]==1&&Data.Chess[i-4][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//斜三连死   
		if((i-4)>=0&&(j+4)<Data.X_number&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==1&&Data.Chess[i-3][j+3]==1&&Data.Chess[i-4][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//斜三连活  
		if((i+4)<Data.X_number&&(j-4)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==1&&Data.Chess[i+3][j-3]==1&&Data.Chess[i+4][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//斜三连死   
		if((i+4)<Data.X_number&&(j-4)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==1&&Data.Chess[i+3][j-3]==1&&Data.Chess[i+4][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		
		//斜2-1连活
		if((i+3)<Data.X_number&&(i-2)>=0&&(j+3)<Data.X_number&&(j-2)>=0&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//斜1-2连活
		if((i+2)<Data.X_number&&(i-3)>=0&&(j+2)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==0&&Data.Chess[i-3][j-3]==0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//斜2-1连死
		if((i+3)<Data.X_number&&(i-2)>=0&&(j+3)<Data.X_number&&(j-2)>=0&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==-1&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//斜2-1连死
		if((i+3)<Data.X_number&&(i-2)>=0&&(j+3)<Data.X_number&&(j-2)>=0&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//斜1-2连死
		if((i+2)<Data.X_number&&(i-3)>=0&&(j+2)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i-3][j-3]==0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//斜1-2连死
		if((i+2)<Data.X_number&&(i-3)>=0&&(j+2)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==0&&Data.Chess[i-3][j-3]==-1&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}

		//斜2-1连活
		if((i+3)<Data.X_number&&(i-2)>=0&&(j+2)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==1&&Data.Chess[i+3][j-3]==0&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//斜1-2连活
		if((i+2)<Data.X_number&&(i-3)>=0&&(j+3)<Data.X_number&&(j-2)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==0&&Data.Chess[i-3][j+3]==0&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Life_3;
		}
		//斜2-1连死
		if((i+3)<Data.X_number&&(i-2)>=0&&(j+2)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==1&&Data.Chess[i+3][j-3]==-1&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//斜2-1连死
		if((i+3)<Data.X_number&&(i-2)>=0&&(j+2)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==1&&Data.Chess[i+3][j-3]==0&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//斜1-2连死
		if((i+2)<Data.X_number&&(i-3)>=0&&(j+3)<Data.X_number&&(j-2)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i-3][j+3]==0&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
		//斜1-2连死
		if((i+2)<Data.X_number&&(i-3)>=0&&(j+3)<Data.X_number&&(j-2)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==0&&Data.Chess[i-3][j+3]==-1&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_Dead_3;
		}
	}
	
	/*
	 * 构建四棋子判断的方法(防守)
	 */
	
	public void Defence_four(int i,int j){
		
		/*
		 * 四棋子横向判断
		 */
		
		//横四连  
		if((i+4)<Data.X_number&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+3][j]==1&&Data.Chess[i+4][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//横四连
		if((i-4)>=0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1&&Data.Chess[i-3][j]==1&&Data.Chess[i-4][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//横3-1连
		if((i+3)<Data.X_number&&(i-1)>=0&&Data.Chess[i+1][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+3][j]==1&&Data.Chess[i-1][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//横1-3连
		if((i+1)<Data.X_number&&(i-3)>=0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1&&Data.Chess[i-3][j]==1&&Data.Chess[i+1][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//横2-2连
		if((i+2)<Data.X_number&&(i-2)>=0&&Data.Chess[i-1][j]==1&&Data.Chess[i-2][j]==1&&Data.Chess[i+2][j]==1&&Data.Chess[i+1][j]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		
		/*
		 * 四棋子纵向判断
		 */
		
		//纵四连   
		if((j+4)<Data.X_number&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==1&&Data.Chess[i][j+4]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//纵四连
		if((j-4)>=0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1&&Data.Chess[i][j-3]==1&&Data.Chess[i][j-4]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//纵3-1连
		if((j+3)<Data.X_number&&(j-1)>=0&&Data.Chess[i][j+1]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+3]==1&&Data.Chess[i][j-1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//纵1-3连
		if((j+1)<Data.X_number&&(j-3)>=0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1&&Data.Chess[i][j-3]==1&&Data.Chess[i][j+1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//纵2-2连
		if((j+2)<Data.X_number&&(j-2)>=0&&Data.Chess[i][j-1]==1&&Data.Chess[i][j-2]==1&&Data.Chess[i][j+2]==1&&Data.Chess[i][j+1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		
		/*
		 * 四棋子斜向判断
		 */
		
		//斜四连  
		if((i+4)<Data.X_number&&(j+4)<Data.X_number&&Data.Chess[i+1][j+1]==1&&(j+4)<Data.X_number&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==1&&Data.Chess[i+4][j+4]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		} 
		//斜四连
		if((i-4)>=0&&(j-4)>=0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1&&Data.Chess[i-3][j-3]==1&&Data.Chess[i-4][j-4]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//斜四连
		if((i-4)>=0&&(j+4)<Data.X_number&&Data.Chess[i-1][j+1]==1&&Data.Chess[i-2][j+2]==1&&Data.Chess[i-3][j+3]==1&&Data.Chess[i-4][j+4]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//斜四连
		if((i+4)<Data.X_number&&(j-4)>=0&&Data.Chess[i+1][j-1]==1&&Data.Chess[i+2][j-2]==1&&Data.Chess[i+3][j-3]==1&&Data.Chess[i+4][j-4]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		
		//斜3-1连
		if((i+3)<Data.X_number&&(i-1)>=0&&(j+3)<Data.X_number&&(j-1)>=0&&Data.Chess[i+1][j+1]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+3][j+3]==1&&Data.Chess[i-1][j-1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//斜1-3连
		if((i+1)<Data.X_number&&(i-3)>=0&&(j+1)<Data.X_number&&(j-3)>=0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1&&Data.Chess[i-3][j-3]==1&&Data.Chess[i+1][j+1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		//斜2-2连
		if((i+2)<Data.X_number&&(i-2)>=0&&(j+2)<Data.X_number&&(j-2)>=0&&Data.Chess[i-1][j-1]==1&&Data.Chess[i-2][j-2]==1&&Data.Chess[i+2][j+2]==1&&Data.Chess[i+1][j+1]==1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Value_4;
		}
		
	}
	
	/*
	 * 构建形成双棋子的方法(进攻)
	 */
	
	public void Attack_two(int i,int j){
		if((j+1)<Data.X_number&&Data.Chess[i][j+1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_2;
		}
		if((i+1)<Data.X_number&&(j+1)<Data.X_number&&Data.Chess[i+1][j+1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_2;
		}
		if((i-1)>=0&&(j+1)<Data.X_number&&Data.Chess[i-1][j+1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_2;
		}
		if((i+1)<Data.X_number&&Data.Chess[i+1][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_2;
		}
		if((i-1)>=0&&Data.Chess[i-1][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_2;
		}
		if((i+1)<Data.X_number&&(j-1)>=0&&Data.Chess[i+1][j-1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_2;
		}
		if((i-1)>=0&&(j-1)>=0&&Data.Chess[i-1][j-1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_2;
		}
		if((j-1)>=0&&Data.Chess[i][j-1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_2;
		}
		
	}
	
	/*
	 * 构建形成3棋子的方法(进攻)
	 */
	public void Attack_three(int i,int j){
		/*
		 * 横向形成3棋子的方法
		 */
		
		//中间不空子
		if((i+4)<Data.X_number&&Data.Chess[i+1][j]==-1&&Data.Chess[i+2][j]==-1&&Data.Chess[i+3][j]==0&&Data.Chess[i+4][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i+3)<Data.X_number&&(i-1)>=0&&Data.Chess[i+1][j]==-1&&Data.Chess[i+2][j]==-1&&Data.Chess[i+3][j]==0&&Data.Chess[i-1][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i+2)<Data.X_number&&(i-2)>=0&&Data.Chess[i+1][j]==-1&&Data.Chess[i+2][j]==-1&&Data.Chess[i-1][j]==0&&Data.Chess[i-2][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-4)>=0&&Data.Chess[i-1][j]==-1&&Data.Chess[i-2][j]==-1&&Data.Chess[i-3][j]==0&&Data.Chess[i-4][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-3)>=0&&(i+1)<Data.X_number&&Data.Chess[i-1][j]==-1&&Data.Chess[i-2][j]==-1&&Data.Chess[i-3][j]==0&&Data.Chess[i+1][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-2)>=0&&(i+2)<Data.X_number&&Data.Chess[i-1][j]==-1&&Data.Chess[i-2][j]==-1&&Data.Chess[i+1][j]==0&&Data.Chess[i+2][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		//中间空1子
		if((i+4)<Data.X_number&&Data.Chess[i+1][j]==0&&Data.Chess[i+2][j]==-1&&Data.Chess[i+3][j]==-1&&Data.Chess[i+4][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i+3)<Data.X_number&&(i-1)>=0&&Data.Chess[i+1][j]==0&&Data.Chess[i+2][j]==-1&&Data.Chess[i+3][j]==-1&&Data.Chess[i-1][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-4)>=0&&Data.Chess[i-1][j]==0&&Data.Chess[i-2][j]==-1&&Data.Chess[i-3][j]==-1&&Data.Chess[i-4][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-3)>=0&&(i+1)<Data.X_number&&Data.Chess[i-1][j]==0&&Data.Chess[i-2][j]==-1&&Data.Chess[i-3][j]==-1&&Data.Chess[i+1][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		//中间空2子
		if((i+4)<Data.X_number&&Data.Chess[i+1][j]==0&&Data.Chess[i+2][j]==0&&Data.Chess[i+3][j]==-1&&Data.Chess[i+4][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-4)>=0&&Data.Chess[i-1][j]==0&&Data.Chess[i-2][j]==0&&Data.Chess[i-3][j]==-1&&Data.Chess[i-4][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		/*
		 * 纵向形成3子
		 */
		
		//中间不空子
		if((j+4)<Data.X_number&&Data.Chess[i][j+1]==-1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==0&&Data.Chess[i][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((j+3)<Data.X_number&&(j-1)>=0&&Data.Chess[i][j+1]==-1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==0&&Data.Chess[i][j-1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((j+2)<Data.X_number&&(j-2)>=0&&Data.Chess[i][j+1]==-1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j-1]==0&&Data.Chess[i][j-2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((j-4)>=0&&Data.Chess[i][j-1]==-1&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j-3]==0&&Data.Chess[i][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((j-3)>=0&&(j+1)<Data.X_number&&Data.Chess[i][j-1]==-1&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j-3]==0&&Data.Chess[i][j+1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((j-2)>=0&&(j+2)<Data.X_number&&Data.Chess[i][j-1]==-1&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j+1]==0&&Data.Chess[i][j+2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		//中间空1子
		if((j+4)<Data.X_number&&Data.Chess[i][j+1]==0&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==-1&&Data.Chess[i][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((j+3)<Data.X_number&&(j-1)>=0&&Data.Chess[i][j+1]==0&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==-1&&Data.Chess[i][j-1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((j-4)>=0&&Data.Chess[i][j-1]==0&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j-3]==-1&&Data.Chess[i][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((j-3)>=0&&(j+1)<Data.X_number&&Data.Chess[i][j-1]==0&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j-3]==-1&&Data.Chess[i][j+1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		//中间空2子
		if((j+4)<Data.X_number&&Data.Chess[i][j+1]==0&&Data.Chess[i][j+2]==0&&Data.Chess[i][j+3]==-1&&Data.Chess[i][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((j-4)>=0&&Data.Chess[i][j-1]==0&&Data.Chess[i][j-2]==0&&Data.Chess[i][j-3]==-1&&Data.Chess[i][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		/*
		 * 斜向形成3子
		 */
		
		//中间不空子
		if((j+4)<Data.X_number&&(i+4)<Data.X_number&&Data.Chess[i+1][j+1]==-1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==0&&Data.Chess[i+4][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i+3)<Data.X_number&&(i-1)>=0&&(j+3)<Data.X_number&&(j-1)>=0&&Data.Chess[i+1][j+1]==-1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==0&&Data.Chess[i-1][j-1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i+2)<Data.X_number&&(i-2)>=0&&(j+2)<Data.X_number&&(j-2)>=0&&Data.Chess[i+1][j+1]==-1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i-1][j-1]==0&&Data.Chess[i-2][j-2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-4)>=0&&(j-4)>=0&&Data.Chess[i-1][j-1]==-1&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-3][j-3]==0&&Data.Chess[i-4][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-3)>=0&&(i+1)<Data.X_number&&(j-3)>=0&&(j+1)<Data.X_number&&Data.Chess[i-1][j-1]==-1&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-3][j-3]==0&&Data.Chess[i+1][j+1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-2)>=0&&(i+2)<Data.X_number&&(j-2)>=0&&(j+2)<Data.X_number&&Data.Chess[i-1][j-1]==-1&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i+1][j+1]==0&&Data.Chess[i+2][j+2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		if((j-4)>=0&&(i+4)<Data.X_number&&Data.Chess[i+1][j-1]==-1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==0&&Data.Chess[i+4][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i+3)<Data.X_number&&(i-1)>=0&&(j+1)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j-1]==-1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==0&&Data.Chess[i-1][j+1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i+2)<Data.X_number&&(i-2)>=0&&(j+2)<Data.X_number&&(j-2)>=0&&Data.Chess[i+1][j-1]==-1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i-1][j+1]==0&&Data.Chess[i-2][j+2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-4)>=0&&(j+4)<Data.X_number&&Data.Chess[i-1][j+1]==-1&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i-3][j+3]==0&&Data.Chess[i-4][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-3)>=0&&(i+1)<Data.X_number&&(j-1)>=0&&(j+3)<Data.X_number&&Data.Chess[i-1][j+1]==-1&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i-3][j+3]==0&&Data.Chess[i+1][j-1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-2)>=0&&(i+2)<Data.X_number&&(j-2)>=0&&(j+2)<Data.X_number&&Data.Chess[i-1][j+1]==-1&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i+1][j-1]==0&&Data.Chess[i+2][j-2]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		//中间空1子
		if((i+4)<Data.X_number&&(j+4)<Data.X_number&&Data.Chess[i+1][j+1]==0&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==-1&&Data.Chess[i+4][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i+3)<Data.X_number&&(i-1)>=0&&(j+3)<Data.X_number&&(j-1)>=0&&Data.Chess[i+1][j+1]==0&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==-1&&Data.Chess[i-1][j-1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-4)>=0&&(j-4)>=0&&Data.Chess[i-1][j-1]==0&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-3][j-3]==-1&&Data.Chess[i-4][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-3)>=0&&(i+1)<Data.X_number&&(j-3)>=0&&(j+1)<Data.X_number&&Data.Chess[i-1][j-1]==0&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-3][j-3]==-1&&Data.Chess[i+1][j+1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		
		if((i+4)<Data.X_number&&(j-4)>=0&&Data.Chess[i+1][j-1]==0&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==-1&&Data.Chess[i+4][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i+3)<Data.X_number&&(i-1)>=0&&(j+1)<Data.X_number&&(j-3)>=0&&Data.Chess[i+1][j-1]==0&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==-1&&Data.Chess[i-1][j+1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-4)>=0&&(j+4)<Data.X_number&&Data.Chess[i-1][j+1]==0&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i-3][j+3]==-1&&Data.Chess[i-4][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-3)>=0&&(i+1)<Data.X_number&&(j-1)>=0&&(j+3)<Data.X_number&&Data.Chess[i-1][j+1]==0&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i-3][j+3]==-1&&Data.Chess[i+1][j-1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		
		//中间空2子
		if((i+4)<Data.X_number&&(j+4)<Data.X_number&&Data.Chess[i+1][j+1]==0&&Data.Chess[i+2][j+2]==0&&Data.Chess[i+3][j+3]==-1&&Data.Chess[i+4][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-4)>=0&&(j-4)>=0&&Data.Chess[i-1][j-1]==0&&Data.Chess[i-2][j-2]==0&&Data.Chess[i-3][j-3]==-1&&Data.Chess[i-4][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		
		if((i+4)<Data.X_number&&(j-4)>=0&&Data.Chess[i+1][j-1]==0&&Data.Chess[i+2][j-2]==0&&Data.Chess[i+3][j-3]==-1&&Data.Chess[i+4][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
		if((i-4)>=0&&(j+4)<Data.X_number&&Data.Chess[i-1][j+1]==0&&Data.Chess[i-2][j+2]==0&&Data.Chess[i-3][j+3]==-1&&Data.Chess[i-4][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_3;
		}
	}
	
	/*
	 * 构建形成4棋子的方法(进攻)
	 */
	public void Attack_four(int i,int j){
		/*
		 * 横向形成4棋子
		 */
		
		//中间不空子
		if((i+4)<Data.X_number&&Data.Chess[i+1][j]==-1&&Data.Chess[i+2][j]==-1&&Data.Chess[i+3][j]==-1&&Data.Chess[i+4][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((i-4)>=0&&Data.Chess[i-1][j]==-1&&Data.Chess[i-2][j]==-1&&Data.Chess[i-3][j]==-1&&Data.Chess[i-4][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((i+3)<Data.X_number&&(i-1)>=0&&Data.Chess[i+1][j]==-1&&Data.Chess[i+2][j]==-1&&Data.Chess[i+3][j]==-1&&Data.Chess[i-1][j]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		
		//中间空1子
		if((i+4)<Data.X_number&&Data.Chess[i+1][j]==0&&Data.Chess[i+2][j]==-1&&Data.Chess[i+3][j]==-1&&Data.Chess[i+4][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((i-4)>=0&&Data.Chess[i-1][j]==0&&Data.Chess[i-2][j]==-1&&Data.Chess[i-3][j]==-1&&Data.Chess[i-4][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		
		/*
		 * 纵向形成4棋子
		 */
		
		//中间不空子
		if((j+4)<Data.X_number&&Data.Chess[i][j+1]==-1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==-1&&Data.Chess[i][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((j-4)>=0&&Data.Chess[i][j-1]==-1&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j-3]==-1&&Data.Chess[i][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((j+3)<Data.X_number&&(j-1)>=0&&Data.Chess[i][j+1]==-1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==-1&&Data.Chess[i][j-1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		//中间空1子
		if((j+4)<Data.X_number&&Data.Chess[i][j+1]==0&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==-1&&Data.Chess[i][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((j-4)>=0&&Data.Chess[i][j-1]==0&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j-3]==-1&&Data.Chess[i][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		
		/*
		 * 斜向形成4棋子
		 */
		
		//中间不空子
		if((j+4)<Data.X_number&&(i+4)<Data.X_number&&Data.Chess[i+1][j+1]==-1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==-1&&Data.Chess[i+4][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((j-4)>=0&&(i-4)>=0&&Data.Chess[i-1][j-1]==-1&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-3][j-3]==-1&&Data.Chess[i-4][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		
		if((j-4)>=0&&(i+4)<Data.X_number&&Data.Chess[i+1][j-1]==-1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==-1&&Data.Chess[i+4][j-4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((j+4)<Data.X_number&&(i-4)>=0&&Data.Chess[i-1][j+1]==-1&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i-3][j+3]==-1&&Data.Chess[i-4][j+4]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		
		if((i+3)<Data.X_number&&(i-1)>=0&&(j+3)<Data.X_number&&(j-1)>=0&&Data.Chess[i+1][j+1]==-1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==-1&&Data.Chess[i-1][j-1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((i-3)>=0&&(i+1)<Data.X_number&&(j-3)>=0&&(j+1)<Data.X_number&&Data.Chess[i-1][j-1]==-1&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-3][j-3]==-1&&Data.Chess[i+1][j+1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		
		if((i+3)<Data.X_number&&(i-1)>=0&&(j-3)>=0&&(j+1)<Data.X_number&&Data.Chess[i+1][j-1]==-1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==-1&&Data.Chess[i-1][j+1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((i-3)>=0&&(i+1)<Data.X_number&&(j+3)<Data.X_number&&(j-1)>=0&&Data.Chess[i-1][j+1]==-1&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i-3][j+3]==-1&&Data.Chess[i+1][j-1]==0){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		
		
		//中间空1子
		if((j+4)<Data.X_number&&(i+4)<Data.X_number&&Data.Chess[i+1][j+1]==0&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==-1&&Data.Chess[i+4][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((j-4)>=0&&(i-4)>=0&&Data.Chess[i-1][j-1]==0&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-3][j-3]==-1&&Data.Chess[i-4][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}

		
		if((j-4)>=0&&(i+4)<Data.X_number&&Data.Chess[i+1][j-1]==0&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==-1&&Data.Chess[i+4][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
		if((j+4)<Data.X_number&&(i-4)>=0&&Data.Chess[i-1][j+1]==0&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i-3][j+3]==-1&&Data.Chess[i-4][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_4;
		}
	}
	
	/*
	 * 构建形成5棋子的方法(进攻)
	 */
	
	public void Attack_five(int i,int j){
		/*
		 * 横向形成5棋子
		 */
		
		if((j+4)<Data.Y_number&&Data.Chess[i][j+1]==-1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==-1&&Data.Chess[i][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((j+3)<Data.Y_number&&(j-1)>=0&&Data.Chess[i][j+1]==-1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j+3]==-1&&Data.Chess[i][j-1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((j+2)<Data.Y_number&&(j-2)>=0&&Data.Chess[i][j+1]==-1&&Data.Chess[i][j+2]==-1&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j-1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((j+1)<Data.Y_number&&(j-3)>=0&&Data.Chess[i][j-1]==-1&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j-3]==-1&&Data.Chess[i][j+1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((j-4)>=0&&Data.Chess[i][j-1]==-1&&Data.Chess[i][j-2]==-1&&Data.Chess[i][j-3]==-1&&Data.Chess[i][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		
		/*
		 * 纵向形成5棋子
		 */
		
		if((i+4)<Data.Y_number&&Data.Chess[i+1][j]==-1&&Data.Chess[i+2][j]==-1&&Data.Chess[i+3][j]==-1&&Data.Chess[i+4][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+3)<Data.Y_number&&(i-1)>=0&&Data.Chess[i+1][j]==-1&&Data.Chess[i+2][j]==-1&&Data.Chess[i+3][j]==-1&&Data.Chess[i-1][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+2)<Data.Y_number&&(i-2)>=0&&Data.Chess[i+1][j]==-1&&Data.Chess[i+2][j]==-1&&Data.Chess[i-2][j]==-1&&Data.Chess[i-1][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+1)<Data.Y_number&&(i-3)>=0&&Data.Chess[i-1][j]==-1&&Data.Chess[i-2][j]==-1&&Data.Chess[i-3][j]==-1&&Data.Chess[i+1][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i-4)>=0&&Data.Chess[i-1][j]==-1&&Data.Chess[i-2][j]==-1&&Data.Chess[i-3][j]==-1&&Data.Chess[i-4][j]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		
		/*
		 * 斜向形成5棋子
		 */
		
		if((i+4)<Data.Y_number&&(j+4)<Data.Y_number&&Data.Chess[i+1][j+1]==-1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==-1&&Data.Chess[i+4][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+3)<Data.Y_number&&(i-1)>=0&&(j+3)<Data.Y_number&&(j-1)>=0&&Data.Chess[i+1][j+1]==-1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i+3][j+3]==-1&&Data.Chess[i-1][j-1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+2)<Data.Y_number&&(i-2)>=0&&(j+2)<Data.Y_number&&(j-2)>=0&&Data.Chess[i+1][j+1]==-1&&Data.Chess[i+2][j+2]==-1&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-1][j-1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+1)<Data.Y_number&&(i-3)>=0&&(j+1)<Data.Y_number&&(j-3)>=0&&Data.Chess[i-1][j-1]==-1&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-3][j-3]==-1&&Data.Chess[i+1][j+1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i-4)>=0&&(j-4)>=0&&Data.Chess[i-1][j-1]==-1&&Data.Chess[i-2][j-2]==-1&&Data.Chess[i-3][j-3]==-1&&Data.Chess[i-4][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		
		if((i-4)>=0&&(j+4)<Data.Y_number&&Data.Chess[i-1][j+1]==-1&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i-3][j+3]==-1&&Data.Chess[i-4][j+4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+1)<Data.Y_number&&(i-3)>=0&&(j+3)<Data.Y_number&&(j-1)>=0&&Data.Chess[i-1][j+1]==-1&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i-3][j+3]==-1&&Data.Chess[i+1][j-1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+2)<Data.Y_number&&(i-2)>=0&&(j+2)<Data.Y_number&&(j-2)>=0&&Data.Chess[i-1][j+1]==-1&&Data.Chess[i-2][j+2]==-1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+1][j-1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+3)<Data.Y_number&&(i-1)>=0&&(j+1)<Data.Y_number&&(j-3)>=0&&Data.Chess[i+1][j-1]==-1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==-1&&Data.Chess[i-1][j+1]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
		if((i+4)<Data.Y_number&&(j-4)>=0&&Data.Chess[i+1][j-1]==-1&&Data.Chess[i+2][j-2]==-1&&Data.Chess[i+3][j-3]==-1&&Data.Chess[i+4][j-4]==-1){
			Data.Value[i][j]=Data.Value[i][j]+Data.Attack_Value_5;
		}
	}
	
	/**
	 * 清空权值表的方法
	 */
	public void ReFresh_Value(){
		for(int i=0;i<Data.X_number;i++){
			for(int j=0;j<Data.Y_number;j++){
				Data.Value[i][j]=0;
				
			}
		}
	}
	

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO 自动生成的方法存根
		
	}

}

?

使用方法

先点击 新的一局 再来选择是比赛方式 玩家之间对战或者玩家与电脑对战。

悔棋每次只悔一个棋子。

在重新开始时,点击新的一局或者是任何一种比赛方式都可。

  • 相关文章
发表评论
用户名: 匿名