简单,而且能看懂,看懂之后可以修改。但算法简单制约了Ai的智能。对于懒惰的朋友,可以借鉴。
package com.junnet.game.wuziqi;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.junnet.wifitransfer.tools.DebugUtils;
import android.annotation.SuppressLint;
/**
* 没想到憨憨的猪八戒 智商竟然比较高,你能让他智商更高吗?期待你的表现.
*
* @author dyl
*
*/
@SuppressLint("UseSparseArrays")
public class ZhuBaJie {
// 棋盘的宽度、高度、棋盘的模式(如20×15)
private int width, height;
// 棋盘方格的横向、纵向坐标
private int x = 0, y = 0;
// Map<Integer, Point> map;
PlayerAI AI;
// 棋盘方格的横向、纵向坐标所对应的棋子颜色,
// 数组arrMapShow只有4个值:1,2,3,-5,
// 其中1代表该棋盘方格上下的棋子为黑子,
// 2代表该棋盘方格上下的棋子为白子,
// 3代表为该棋盘方格上没有棋子,
// -5代表该棋盘方格不能够下棋子
private int[][] arrMapShow;
// 交换棋手的标识,棋盘方格上是否有棋子的标识符
static final String TAG = ZhuBaJie.class.getSimpleName();
private Point point;
int qizhi;
public ZhuBaJie(int mGridArray[][], int qizhi, int width, int height,
boolean center) {
arrMapShow = mGridArray;
this.qizhi = qizhi;
this.width = width;
this.height = height;
point = new Point();
setPoint(arrMapShow.length / 2, arrMapShow.length / 2);
// computerDo(width, height);
}
void setPoint(int x, int y) {
point.setX(x);
point.setY(y);
point.setQizhi(this.qizhi);
}
public ZhuBaJie(int mGridArray[][], int qizhi, int width, int height) {
arrMapShow = mGridArray;
this.qizhi = qizhi;
this.width = width;
this.height = height;