• 大小: 1.54MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-02
  • 语言: Java
  • 标签:

资源简介

采用的编码格式为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个文件信息

评论

共有 条评论