< chessboard.length; i++) {for (int j = 0; j < chessboard.length; j++) {this.chessboard[i][j]=0;}}}//下棋,x和y分别是人下棋的横坐标和纵坐标,电脑根据坐标来判断下棋位置下棋public void getMove(int x,int y) {//人下棋if(this.color==1)this.chessboard[x][y]=2;elsethis.chessboard[x][y]=1;System.out.println("人下棋:("+x+","+y+")");print();if(isWin(x,y)) {System.out.println("人获胜");System.exit(0);}else if(isFull()) {System.out.println("平局");System.exit(0);}//存储所有未下棋的位置ArrayList positions=new ArrayList<>();//存储每个位置的评分ArrayList numbers=new ArrayList<>();for (int i = 0; i < chessboard.length; i++) {for (int j = 0; j < chessboard.length; j++) {positions.add(new position(i,j));numbers.add(numJudge(i,j));}}int index = 0;// 最高评分在numbers中的下标for (int i = 0; i < numbers.size(); i++) {if (numbers.get(i) > numbers.get(index)) {index = i;}}// 储存所有最高评分在numbers中的下标(当最高评分有多个时)ArrayList max = new ArrayList<>();for (int i = 0; i < numbers.size(); i++) {if (numbers.get(i) == numbers.get(index)) {max.add(i);}}//电脑下棋if(max.size()==1){System.out.println("电脑下棋:("+positions.get(max.get(0)).getX()+","+positions.get(max.get(0)).getY()+")");if(this.color==1)this.chessboard[positions.get(max.get(0)).getX()][positions.get(max.get(0)).getY()]=1;elsethis.chessboard[positions.get(max.get(0)).getX()][positions.get(max.get(0)).getY()]=2;if(isWin(positions.get(max.get(0)).getX(), positions.get(max.get(0)).getY())) {System.out.println("平局");System.exit(0);}}else{index = (int) (Math.random() * max.size());System.out.println("电脑下棋:("+positions.get(max.get(index)).getX()+","+positions.get(max.get(index)).getY()+")");if(this.color==1)this.chessboard[positions.get(max.get(0)).getX()][positions.get(max.get(0)).getY()]=1;elsethis.chessboard[positions.get(max.get(0)).getX()][positions.get(max.get(0)).getY()]=2;if(isWin(positions.get(max.get(0)).getX(), positions.get(max.get(0)).getY())) {System.out.println("电脑获胜");System.exit(0);}else if(isFull()) {System.out.println("平局");System.exit(0);}}print();}//评分算法private int numJudge(int x, int y) {int sum = 0;sum += mark1(x, y);// 左右方向sum += mark2(x, y);// 上下方向sum += mark3(x, y);// 主对角线方向sum += mark4(x, y);// 副对角线方向sum += mark5(x, y);// 八个方向return sum;}// 给分标准1,根据棋型给分private int calculate(int[] position) {int sum = 0;int index = -1;for (int i = 0; i < this.stiuation.length; i++) {if (Arrays.equals(position, this.stiuation[i])) {index = i;if (i < 2) {sum += 100000;// 连5棋型if (color == 1) {if (i == 0) {sum += 10000000;// 我方胜利加分}} else {if (i == 1) {sum += 10000000;// 我方胜利加分}}} else if (i < 6) {sum += 10000;// 活4棋型if(color==1){if(i<=3){sum+=50000;//我方先连4子加分}}else{if(i>3){sum+=50000;//我方先连4子加分}}} else if (i < 10) {sum += 5000;// 眠4棋型} else if (i < 16) {sum += 1000;// 活3棋型if(color==1){if(i<=12){sum+=3000;//我方先连3子加分}}else{if(i>12){sum+=3000;//我方先连3子加分}}} else if (i < 28) {sum += 500;// 眠3棋型} else if (i < 32) {sum += 100;// 活2棋型} else {sum += 50;// 眠2棋型}}}if (index < 0) {sum += 1;// 其它情况}return sum;}// 评分标准2private int calculate2(int[] position) {int sum = 0;for (int i = 0; i < this.stiuation2.length; i++) {if (Arrays.equals(position, this.stiuation2[i])) {if (i < 2) {sum += 100000;// 连5棋型if (color == 1) {if (i == 0) {sum += 10000000;// 一子定胜负加分}} else {if (i == 1) {sum += 10000000;// 一子定胜负加分}}} else if (i < 4) {sum += 10000;// 活4棋型if(color==1){if(i==2){sum+=50000;//我方先连4子加分}}else{if(i==3){sum+=50000;//我方先连4子加分}}} else if (i < 6) {sum += 5000;// 眠4棋型} else if (i < 12) {sum += 1000;// 活3棋型if(color==1){if(i<=8){sum+=3000;//我方先连3子加分}}else{if(i>8){sum+=3000;//我方先连3子加分}}} else {sum += 500;// 眠3棋型}}}return sum;}// 左右方向评分private int mark1(int x, int y) {int[] position = new int[4];if (x - 2 >= 0) {position[0] = this.chessboard[x - 2][y];} else {position[0] = 0;}if (x - 1 >= 0) {position[1] = this.chessboard[x - 1][y];} else {position[1] = 0;}if (x + 1