📄 chesscompute.java~3~
字号:
package chess;
public class ChessCompute implements Runnable{
static int COMPUTER = 2;
static int MAN = 1;
int position = 0, bestX = 0, bestY = 0;
int board[][] = new int[16][16];
int InputX,InputY;
public ChessCompute() { //构造函数,初始化棋盘
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
board[i][j] = 0;
}
}
}
private void updateChessboard(int x, int y, int who) {
board[x][y] = who; //who走到了x,y
}
public void getNextPositon(int x, int y) {
this.updateChessboard(x, y, MAN); //人走到x,y-->更新了board[][]
Analyse aa = new Analyse(this.board);
this.position = aa.computerDo();
this.bestY = position % 100 - 1;
this.bestX = position / 100 - 1; //分析得到电脑最佳的下一步
this.updateChessboard(this.bestX, this.bestY, COMPUTER); //电脑走了bestX,bestY,更新board[][]
}
public int getBestX(){
return this.bestX;
}
public int getBestY(){
return this.bestY;
}
public void setInputX(int x){
InputX=x;
}
public void setInputY(int y){
InputY=y;
}
public void run(){
this.getNextPositon(inputX,inputY);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -