资源简介
采用的编码格式为utf8,java实现的五子棋,运用java的Swing,实现了一个splash加载界面,实现了悔棋操作,读档和存档操作,切换背景的操作,简单中级困难的难度选择。
代码片段和文件信息
package com.fivechess;
/**
* 防御优先
* @author mzy
*
*/
public class Calculation01 {
FiveChessBord f = new FiveChessBord();
private static final int LINE_COUNT = FiveChessBord.getLineCount();
private static final int WHITE = FiveChessBord.getWhite();
private int[][] chesses; // = f.getChess(); // 为什么直接使用get不行
private int[] gkey = f.getKeyValues();
private String[] bkey = f.getBlackKey();
private String[] wkey = f.getWhiteKey();
int[] res = new int[2];
public Calculation01(int[][] items) {
this.chesses = items;
}
public int[] computerPlay() {
int tmax = 0 wmax = 0;
int r = 0 c = 0;
for (int i = 0; i < LINE_COUNT; i++) {
for (int j = 0; j < LINE_COUNT; j++) {
if (chesses[i][j] != 0) {
continue;
}
tmax = getValue(0 i j);
if (tmax > wmax) {
wmax = tmax;
r = i;
c = j;
}
}
}
chesses[r][c] = WHITE;
res[0] = r;
res[1] = c;
return res;
}
public String chessString(int chessColor int row int col int rowInc int colInc) {
StringBuilder strB = new StringBuilder(“A“);
int r = row;
int c = col;
int i = 0;
while (i < 4) {
i++;
r = r + rowInc;
c = c + colInc;
if (r < LINE_COUNT && r >= 0 && c < LINE_COUNT && c >= 0) {
strB.append(chesses[r][c]);
}
}
r = row;
c = col;
i = 0;
while (i < 4) {
i++;
r = r - rowInc;
c = c - colInc;
if (r < LINE_COUNT && r >= 0 && c < LINE_COUNT && c >= 0)
strB.insert(0 chesses[r][c]);
}
return strB.toString();
}
public int getValue(int chessColor int row int col) {//// 获取周围空处的值,取价值最大的点
int bmax = 0 wmax = 0;
String[] t = new String[4];
t[0] = chessString(chessColor row col 0 1);
t[1] = chessString(chessColor row col 1 0);
t[2] = chessString(chessColor row col 1 1);
t[3] = chessString(chessColor row col 1 -1);
for (int i = 0; i < 4; i++) {
String b = t[i].replaceAll(“A“ String.valueOf(1));
String w = t[i].replaceAll(“A“ String.valueOf(2));
for (int j = 0; j < bkey.length; j++) {
if (b.indexOf(bkey[j]) >= 0) {
if (gkey[j] > bmax) {
bmax = gkey[j];
}
}
}
for (int j = 0; j < wkey.length; j++) {
if (w.indexOf(bkey[j]) >= 0) {
if (gkey[j] > wmax)
wmax = gkey[j];
}
}
}
return bmax > wmax ? bmax : wmax;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 353 2017-12-27 19:59 fiveChess\.classpath
文件 385 2017-12-25 14:53 fiveChess\.project
文件 57 2017-12-27 18:13 fiveChess\.settings\org.eclipse.core.resources.prefs
文件 598 2017-12-25 14:53 fiveChess\.settings\org.eclipse.jdt.core.prefs
文件 1203 2017-12-30 14:31 fiveChess\bin\com\fivechess\AboutAuthor.class
文件 1200 2017-12-30 14:31 fiveChess\bin\com\fivechess\AboutHelp.class
文件 2911 2017-12-30 14:31 fiveChess\bin\com\fivechess\Calculation01.class
文件 3431 2017-12-30 14:31 fiveChess\bin\com\fivechess\Calculation02.class
文件 3442 2018-01-01 17:07 fiveChess\bin\com\fivechess\Calculation03.class
文件 332 2017-12-30 14:31 fiveChess\bin\com\fivechess\Chess.class
文件 8375 2017-12-30 14:31 fiveChess\bin\com\fivechess\FiveChess.class
文件 2936 2017-12-30 14:31 fiveChess\bin\com\fivechess\FiveChessBord$ChessListener.class
文件 7533 2017-12-30 14:31 fiveChess\bin\com\fivechess\FiveChessBord.class
文件 1581 2017-12-30 14:31 fiveChess\bin\com\fivechess\Music.class
文件 1203 2017-12-30 14:31 fiveChess\bin\com\fivechess\Splash.class
文件 1354738 2017-12-26 15:45 fiveChess\img\background.png
文件 96438 2017-12-26 19:14 fiveChess\img\backgroundChess.png
文件 11856 2017-12-26 15:23 fiveChess\img\black.png
文件 1240 2017-12-26 19:10 fiveChess\img\blackchess.GIF
文件 43959 2017-12-26 15:30 fiveChess\img\start.jpg
文件 14784 2017-12-26 15:23 fiveChess\img\timg.jpg
文件 11493 2017-12-26 15:23 fiveChess\img\white.png
文件 1603 2017-12-26 19:10 fiveChess\img\whitechess.GIF
文件 12683 2017-12-27 19:58 fiveChess\lib\audio.jar
文件 225 2017-12-29 08:30 fiveChess\programFile\data
文件 12632 2017-12-27 11:41 fiveChess\sound\lost.wav
文件 4924 2017-12-27 11:41 fiveChess\sound\put.wav
文件 54958 2017-12-27 11:41 fiveChess\sound\win.wav
文件 2457 2017-12-29 09:03 fiveChess\src\com\fivechess\Calculation01.java
文件 3115 2017-12-29 09:04 fiveChess\src\com\fivechess\Calculation02.java
............此处省略20个文件信息
- 上一篇:JSP人力资源管理系统源代码+数据库
- 下一篇:数据结构java版练习试卷及答案
相关资源
- java五子棋项目源代码
- 自己写的java人机五子棋源码
- java五子棋游戏(源码)
- JAVA五子棋游戏简单人工智能算法
- java五子棋以及毕业论文
- Android手机版Java五子棋源代码【源代码
- 五子棋素材五子棋素材
- Java五子棋局域网联机版
- java五子棋网络版
- java五子棋源码人人
- Java五子棋联机版windowbuilder界面
- JAVA五子棋简单实现
- 基于socket编写的java五子棋
- Java五子棋经典程序,非常详细
- Android手机版Java五子棋源代码
- 网络课程设计 Java五子棋网络版
- 双人玩的Java五子棋游戏
- GUI版Java五子棋源码,可人机对战,经
- Java五子棋游戏(完整项目,eclipse直接
- java五子棋游戏课程设计含源代码
- java五子棋人机对战
- java五子棋 单机版游戏源码
- java五子棋(支持 人机对战、双人对战
- Java五子棋网络对战
- java五子棋人机对战完整源码
- 2020年最新版Java五子棋(可网络对战)
- java五子棋课程设计报告
- java五子棋开题报告
- Java五子棋源码课程设计
- java实现五子棋人机智能对战/人人网络
评论
共有 条评论