资源简介
压缩包内含代码与可执行jar包,直接idea打开就可以运行;
1.在jdk1.8环境下工作,用IDEA开发的JPanel窗口程序
2.功能主要为人机对战,支持悔棋,支持电脑先行(电脑先行一般很难赢它),支持重新开始
3.该五子棋AI使用了五元组的五子棋算法,以五个一组将棋盘分为一个个横竖斜的数组,计算各个组的权重,并不是用的极大极小值剪枝算法,算是一种新的思路,但是这个AI很强!大家都知道黑棋先手必胜,所以黑棋先手的情况下只要认真还是能赢的,但是让AI先行,就不好赢了,我水平很低,下了几把目前没赢过。
1.在jdk1.8环境下工作,用IDEA开发的JPanel窗口程序
2.功能主要为人机对战,支持悔棋,支持电脑先行(电脑先行一般很难赢它),支持重新开始
3.该五子棋AI使用了五元组的五子棋算法,以五个一组将棋盘分为一个个横竖斜的数组,计算各个组的权重,并不是用的极大极小值剪枝算法,算是一种新的思路,但是这个AI很强!大家都知道黑棋先手必胜,所以黑棋先手的情况下只要认真还是能赢的,但是让AI先行,就不好赢了,我水平很低,下了几把目前没赢过。

代码片段和文件信息
package fiveBord;
public class Chessman extends DrawChessBoard{
private int color; //1-white,0-black
private boolean placed = false;
private int stepNum = 0;
private int computerPieceX = 0;
private int computerPieceY = 0;
private int score; //对该位置的打的分数
public Chessman(int colorboolean placedint stepNumint computerPieceXint computerPieceY int score){
this.color=color;
this.placed=placed;
this.stepNum=stepNum;
this.computerPieceX=computerPieceX;
this.computerPieceY=computerPieceY;
this.score=score;
}
public boolean getPlaced() {
return placed;
}
public void setPlaced(boolean placed) {
this.placed = placed;
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public int getStepNum() {
return stepNum;
}
public void setStepNum(int stepNum) {
this.stepNum = stepNum;
}
public int getComputerPieceX() {
return computerPieceX;
}
public void setComputerPieceX(int computerPieceX) {
this.computerPieceX = computerPieceX;
}
public int getComputerPieceY() {
return computerPieceY;
}
public void setComputerPieceY(int computerPieceY) {
this.computerPieceY = computerPieceY;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
//电脑落子
public Chessman computerPiece(int computerColorChessman[][] cm){
//每次都初始化下score评分数组
int[][] chessboard = new int[ROWS][ROWS]; //与界面棋盘对应,0代表空,-1代表机器,1代表人类
int[][] score = new int[ROWS][ROWS]; //每个位置得分
for(int i = 0; i < ROWS; i++){
for(int j = 0; j < ROWS; j++){
chessboard[i][j] = 0;
if(cm[i][j]!=null && cm[i][j].getColor()==BLACK){
chessboard[i][j] = 1;
}
if(cm[i][j]!=null && cm[i][j].getColor()==WHITE){
chessboard[i][j] = -1;
}
score[i][j] = 0;
}
}
//每次机器找寻落子位置,评分都重新算一遍(虽然算了很多多余的,因为上次落子时候算的大多都没变)
//先定义一些变量
int humanChessmanNum = 0; //五元组中的黑棋数量
int machineChessmanNum = 0; //五元组中的白棋数量
int tupleScoreTmp = 0; //五元组得分临时变量
int goalX = -1; //目标位置x坐标
int goalY = -1; //目标位置y坐标
int maxScore = -1; //最大分数
//1.扫描横向的15个行
for(int i = 0; i < 15; i++){
for(int j = 0; j < 11; j++){
int k = j;
while(k < j + 5){
if(chessboard[i][k] == -1) machineChessmanNum++;
else if(chessboard[i][k] == 1)humanChessmanNum++;
k++;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-02-19 19:06 FiveBord\
目录 0 2019-02-19 19:06 FiveBord\.idea\
文件 433 2019-02-19 16:53 FiveBord\.idea\FiveBord.iml
目录 0 2019-02-19 19:02 FiveBord\.idea\artifacts\
文件 437 2019-02-19 19:02 FiveBord\.idea\artifacts\FiveBord_jar.xm
文件 384 2019-02-19 16:52 FiveBord\.idea\misc.xm
文件 275 2019-02-19 16:52 FiveBord\.idea\modules.xm
文件 8915 2019-02-14 14:23 FiveBord\.idea\uiDesigner.xm
文件 22056 2019-02-19 19:06 FiveBord\.idea\workspace.xm
文件 433 2019-02-14 14:09 FiveBord\FiveBord.iml
目录 0 2019-02-19 19:06 FiveBord\out\
目录 0 2019-02-19 19:06 FiveBord\out\artifacts\
目录 0 2019-02-19 19:06 FiveBord\out\artifacts\FiveBord_jar\
文件 199062 2019-02-19 19:06 FiveBord\out\artifacts\FiveBord_jar\FiveBord.jar
目录 0 2019-02-19 18:28 FiveBord\out\production\
目录 0 2019-02-19 18:29 FiveBord\out\production\FiveBord\
目录 0 2019-02-19 18:29 FiveBord\out\production\FiveBord\me
文件 52 2019-02-19 18:29 FiveBord\out\production\FiveBord\me
目录 0 2019-02-19 19:05 FiveBord\out\production\FiveBord\fiveBord\
文件 4854 2019-02-19 18:29 FiveBord\out\production\FiveBord\fiveBord\Chessman.class
文件 1248 2019-02-19 18:59 FiveBord\out\production\FiveBord\fiveBord\DrawChessBoard$1.class
文件 1404 2019-02-19 18:59 FiveBord\out\production\FiveBord\fiveBord\DrawChessBoard$2.class
文件 1268 2019-02-19 18:59 FiveBord\out\production\FiveBord\fiveBord\DrawChessBoard$3.class
文件 9143 2019-02-19 18:59 FiveBord\out\production\FiveBord\fiveBord\DrawChessBoard.class
文件 898 2019-02-19 19:05 FiveBord\out\production\FiveBord\fiveBord\Main.class
目录 0 2019-02-19 18:29 FiveBord\out\production\FiveBord\image\
文件 204549 2019-02-19 18:29 FiveBord\out\production\FiveBord\image\chessboard.jpg
目录 0 2019-02-19 18:28 FiveBord\src\
目录 0 2019-02-19 18:28 FiveBord\src\me
文件 52 2019-02-15 10:28 FiveBord\src\me
目录 0 2019-02-19 19:05 FiveBord\src\fiveBord\
............此处省略5个文件信息
- 上一篇:用java编写的火柴游戏
- 下一篇:Android多级下拉列表菜单
相关资源
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
- [免费]java实现有障碍物的贪吃蛇游戏
- java Servlet投票实例
- 操作系统作业 (pv,作业管理,等5个
- 基于C/S架构考试系统(Java)
- java access 仓库管理系统 源码
- 一元多项式相加 java实现
评论
共有 条评论