资源简介

用了 Alpha-beta 算法,可以聊天,可以联机,高端大气上档次的界面,后序正在补充机器学习功能,修改代码。也希望高手给予指点

资源截图

代码片段和文件信息

package com.what21.chess;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.ImageObserver;
import java.io.IOException;

import javax.swing.*;
/**

 * @ClassName:     $ CheckerBoard

 * @Description:   $画棋子棋盘,对外接口paint(),下子,人机人人,联机

 * 

 * @author          $但求心安

 * @version         V1.0  

 * @Date           $2016/12/1/1

 */
public class CheckerBoard extends JPanel implements MouseListener{
private static final long serialVersionUID = 4802277944291967336L;
public String qipan_name=“qipan0.jpg“;//棋盘的图片名
public String qizi1_name=“c5.png“qizi2_name=“c0.png“;//棋子的图片名
public int row=15col=15;//横纵数目
public  int num[][]=new int[15][15];//棋子的状态0为空,1是玩家1,2是电脑或玩家2
public static boolean peo_peo=false;//是否是人人对战1代表是,默认人机,联机被看为人机
public static int count=0;//判断人人下棋者
public static int Inter=0;//联机为1,默认为零
public static int serve=0;//联机的状态,先手为1,后手为0,建立服务器的为先手
public static int canSetChess=1;//是否可以下棋
public static int step=0;
public getC t;
private static int hui[][][]=new int[225][15][15];
Internet int1=new Internet();//客户端
Server ser=new Server();//服务端
public  void paint(Graphics g)
{
super.paint(g);
Image img = new ImageIcon(“img/“ + qipan_name).getImage();
// 调入棋盘图片
g.drawImage(img 0 0 567 567 this);
Image c1 = new ImageIcon(“img/“ + qizi1_name).getImage();
Image c2 = new ImageIcon(“img/“ + qizi2_name).getImage();
//绘制棋盘
for (int i = 0; i < num.length; i++) {
for (int j = 0; j < num[i].length; j++) {
if (num[i][j] == 1) {
g.drawImage(c1 i * 35 + 20 j * 35 + 20 35 35 this);
} else if (num[i][j] == 2) {
g.drawImage(c2 i * 35 + 20 j * 35 + 20 35 35 this);
}
}
// 重绘棋子
}

}


int maxi=0;//电脑的i,j位置
int maxj=0;
/** 

* @title: people 

* @Description: TODO  人下子

* @param @param i
* @param @param j  本文件

* @return void 返回类型 

* @throws 

*/ 
private void people(int i int j)
{
Graphics g = this.getGraphics();
Computer com = new Computer();
Image c1;
if (num[i][j] != 0)// 如果有棋子,提示信息,重新下子
{
JOptionPane.showMessageDialog(null “该位置有棋子,请重新落子“);
return;
} else {
if (peo_peo)// 本机人人对战
{
count++;
if (count % 2 == 1)// 先手下棋
{
c1 = new ImageIcon(“img/“ + qizi1_name).getImage();
num[i][j] = 1;
com.copyChess(num);
if (com.getSame(i j 1) == 5) {
JOptionPane.showMessageDialog(null “先手赢了“);
canSetChess = 3;
}
} else {// 后手下棋
c1 = new ImageIcon(“img/“ + qizi2_name).getImage();
num[i][j] = 2;
com.copyChess(num);
if (com.getSame(i j 2) == 5) {
JOptionPane.showMessageDialog(null “后手赢了“);
canSetChess = 3;
}
}
} else {// 人机对战人下子
c1 = new ImageIcon(“img/“ + qizi1_name).getImage();
canSetChess = 0;
num[i][j] = 1;
if (Inter == 1) {//联机对战,人下子
if (serve == 0)
int1.setChess(i j);
else if (serve == 1)
ser.setChess(i j);
canSetChess = 0

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-11-25 15:53  WuziChess\
     文件         301  2016-05-14 19:29  WuziChess\.classpath
     文件         385  2016-11-25 13:48  WuziChess\.project
     目录           0  2016-11-25 15:53  WuziChess\.settings\
     文件         629  2013-08-28 12:53  WuziChess\.settings\org.eclipse.jdt.core.prefs
     目录           0  2016-12-13 13:32  WuziChess\bin\
     目录           0  2016-12-13 13:32  WuziChess\bin\com\
     目录           0  2016-12-13 13:32  WuziChess\bin\com\what21\
     目录           0  2016-12-13 13:32  WuziChess\bin\com\what21\chess\
     文件        1789  2016-12-13 13:45  WuziChess\bin\com\what21\chess\CheckerBoard$getC.class
     文件        5685  2016-12-13 13:45  WuziChess\bin\com\what21\chess\CheckerBoard.class
     文件         745  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$1.class
     文件         911  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$10.class
     文件         928  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$11.class
     文件        1764  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$12.class
     文件        1097  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$13.class
     文件        1036  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$2.class
     文件         876  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$3.class
     文件         942  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$4.class
     文件        1207  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$5.class
     文件        1283  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$6.class
     文件         995  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$7.class
     文件        1030  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$8.class
     文件        1031  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe$9.class
     文件        5821  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Checkerframe.class
     文件         682  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Clock$1.class
     文件        2736  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Clock.class
     文件         526  2016-12-13 14:35  WuziChess\bin\com\what21\chess\Computer$struct.class
     文件        7390  2016-12-13 14:35  WuziChess\bin\com\what21\chess\Computer.class
     文件        2414  2016-12-13 13:32  WuziChess\bin\com\what21\chess\Internet.class
     文件        1723  2016-12-21 17:10  WuziChess\bin\com\what21\chess\recvMsg.class
............此处省略35个文件信息

评论

共有 条评论