亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? board.java

?? REVERSI ai parts for java
?? JAVA
字號(hào):
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

/**
 * @author Bengi Mizrahi
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class Board {

	static final int EMPTY = -1;
	static final int WHITE = 0;
	static final int BLACK = 1;
	
	short liberties[][] = {{ 3, 5, 5, 5, 5, 5, 5, 3 }, 
							{ 5, 8, 8, 8, 8, 8, 8, 5 },
							{ 5, 8, 7, 6, 6, 7, 8, 5 }, 
							{ 5, 8, 6, 5, 5, 6, 8, 5 }, 
							{ 5, 8, 6, 5, 5, 6, 8, 5 }, 
							{ 5, 8, 7, 6, 6, 7, 8, 5 }, 
							{ 5, 8, 8, 8, 8, 8, 8, 5 }, 
							{ 3, 5, 5, 5, 5, 5, 5, 3 }};

	int[][] boardData;
	int numOfPieces[];
	int potential [];
	public Player player [];
	
	int playingSide;

	public Board (){};
	public Board(int beginnerSide, Player black, Player white) {
		boardData = new int[8][8];
		for (int i = 0; i < 8; i++)
			for (int j = 0; j < 8; j++)
				boardData[i][j] = EMPTY;
		boardData[3][3] = boardData[4][4] = WHITE;
		boardData[3][4] = boardData[4][3] = BLACK;
		numOfPieces = new int[2];
		numOfPieces[WHITE] = 2;
		numOfPieces[BLACK] = 2;
		potential = new int[2];
		potential[WHITE] = 6;
		potential[BLACK] = 6;
		player = new Player [2];
		player [WHITE] = white;
		player [BLACK] = black;
		
		playingSide = beginnerSide;
	}

	public Board myClone () {
		Board b = new Board ();
		b.liberties = new short [8][8];
		b.boardData = new int [8][8];
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				b.liberties [i][j] = liberties [i][j];
				b.boardData [i][j] = boardData [i][j];
			}
		}
		b.numOfPieces = new int [2];
		b.numOfPieces [Board.WHITE] = numOfPieces [Board.WHITE];
		b.numOfPieces [Board.BLACK] = numOfPieces [Board.BLACK];
		b.potential = new int [2];
		b.potential [Board.WHITE] = potential [Board.WHITE];
		b.potential [Board.BLACK] = potential [Board.BLACK];
		b.player = new Player [2];
		b.player [0] = player [0];
		b.player [1] = player [1];
		b.playingSide = playingSide;
		return b;
	}
	
	public int getCell(int i, int j) {
		return boardData[i][j];
	}

	public int getNumOfPieces(int side) {
		return numOfPieces[side];
	}
	
	public int getPotential (int side) {
		return potential [side];
	}
	
	public int evaluatePieceSuperiority (int side) {
		return numOfPieces [side] -
				numOfPieces [opponent (side)];
	}
	
	public int evaluatePotentialMobility (int side) {
		return potential [side] - potential [opponent (side)];
	}
	
	public int evaluateCorners (int side) {
		int WORTH_OF_A_CORNER = 20;
		int w = 0;
		int b = 0;
		int [][] map = {
			{0, 0},
			{0, 7},
			{7, 0},
			{7, 7}
		};
		for (int i = 0; i < 4; i++) {
			if (boardData [map [i][0]][map [i][1]] == Board.BLACK)
				w++;
			else if (boardData [map [i][0]][map [i][1]] == Board.WHITE)
				b++;
		}
		if (side == BLACK) return WORTH_OF_A_CORNER * (b - w);
		else return WORTH_OF_A_CORNER * (w - b);
	}
	
	public int evaluate (int side) {
		return evaluateCorners (side) +
				evaluateMobility (side) +
				evaluatePotentialMobility (side);
	}
	
	public int evaluateMobility (int side) {
		int w = 0;
		int b = 0;
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (islegalMove (i, j, Board.WHITE)) {
					w++;
				}
				if (islegalMove (i, j, Board.BLACK)) {
					b++;
				}
			}
		}
		if (side == BLACK) return b - w;
		else return w - b;
	}
	
	public static int opponent(int side) {
		if (side == WHITE)
			return BLACK;
		else
			return WHITE;
	}

	public void changeTurn() {
		playingSide = opponent(playingSide);
	}
	
	public int getNumOfEmptyCells () {
		return 64 - (numOfPieces [WHITE] + numOfPieces [BLACK]);
	}
	public boolean islegalMove(int row, int column, int who) {

		int x, y;
		boolean legal;
		int step;
		legal = false;

		if (boardData[row][column] == EMPTY) // must be empty
			{
			for (int direction_x = -1; direction_x < 2; direction_x++)
				for (int direction_y = -1; direction_y < 2; direction_y++) {
					step = 0;

					do {
						step++;
						x = column + step * direction_x;
						y = row + step * direction_y;
					} while (
						(x >= 0)
							&& (x < 8)
							&& (y >= 0)
							&& (y < 8)
							&& (boardData[y][x] == opponent(who)));

					if ((x >= 0)
						&& (x < 8)
						&& (y >= 0)
						&& (y < 8)
						&& (step > 1)
						&& (boardData[y][x] == who)) {
						legal = true;
					}
				}
		}

		return legal;

	}

	public void performMove(int row, int column ) {

		int x, y;
		boolean legal;
		int step;
		

		if (islegalMove(row, column, playingSide)){
			
			boardData [row][column] = playingSide;
			numOfPieces[playingSide]++;
			potential[opponent(playingSide)] = potential[opponent(playingSide)] + liberties[row][column];

			for (int f = -1; f <= 1; f++)
				for (int g = -1; g <= 1; g++)
					if ((f != 0 || g != 0) && (row + f)>=0 && (row + f)<8 
						&& (column + g)>=0 && (column + g)<8 ) {
						if(liberties[row + f][column + g]>0)
							liberties[row + f][column + g]--;
					}
									
			for (int direction_x = -1; direction_x < 2; direction_x++) {
				for (int direction_y = -1; direction_y < 2; direction_y++) {
					step = 0;
	
					do {
						step++;
						x = column + step * direction_x;
						y = row + step * direction_y;
					} while (
						(x >= 0) && (x < 8) && (y >= 0) && (y < 8) && (boardData[y][x] == opponent(playingSide)));
	
					if ((x >= 0) && (x < 8) && (y >= 0) && (y < 8) && (step > 1) && (boardData[y][x] == playingSide)) {
						for (int a = 1; a < step; a++) {
							if (boardData[row + direction_y * a][column + direction_x * a] == opponent(playingSide)) {
								numOfPieces[opponent(playingSide)]--;
								numOfPieces[playingSide]++;
								
								if (liberties[row + direction_y * a][column + direction_x * a] > 0) {
    								potential[opponent(playingSide)] = potential[opponent(playingSide)] + liberties[row + direction_y * a][column + direction_x * a];
    								potential[playingSide]   = potential[playingSide] - liberties[row + direction_y * a][column + direction_x * a];
  								}
  									
  									

							} else {
								numOfPieces[playingSide]++;
							}
							
							boardData[row + direction_y * a][column + direction_x * a] = playingSide;
						}
					}
				}
			}
		changeTurn();
		}
	}
	
	public String toString () {
		String s = "\n";
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				switch (boardData [i][j]) {
					case Board.BLACK: s += "B"; break;
					case Board.WHITE: s += "W"; break;
					case Board.EMPTY: s += "-"; break;
				}
			}
			s += "\n";
		}
		return s;
	}
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩电影在线一区二区三区| 日韩亚洲欧美一区| 国产精品天美传媒沈樵| 国产精品一卡二卡在线观看| www国产成人免费观看视频 深夜成人网| 麻豆一区二区三| www国产成人免费观看视频 深夜成人网| 国模无码大尺度一区二区三区| 国产三级欧美三级| 风间由美一区二区av101| 欧美国产日韩a欧美在线观看| 国产成人av电影免费在线观看| 国产精品久久久久一区二区三区| 91蝌蚪porny九色| 无吗不卡中文字幕| 精品国产成人系列| 不卡大黄网站免费看| 亚洲成精国产精品女| 欧美精品一区二区三区视频| av一本久道久久综合久久鬼色| 一区二区三区日韩在线观看| 欧美一区二区三区播放老司机| 久久国产精品露脸对白| 国产精品久久久久三级| 欧美色图天堂网| 国产在线精品免费| 伊人一区二区三区| 精品免费国产二区三区| 99久精品国产| 蜜桃精品在线观看| 中文字幕日本不卡| 欧美人与性动xxxx| 国产jizzjizz一区二区| 夜夜精品视频一区二区| 久久网站最新地址| 欧美日韩免费一区二区三区视频| 狠狠久久亚洲欧美| 亚洲一区二区在线免费看| 精品女同一区二区| 欧美日韩一二三| 不卡一区二区三区四区| 久久精品免费看| 亚洲综合在线电影| 欧美国产欧美综合| 538在线一区二区精品国产| 国产+成+人+亚洲欧洲自线| 日日夜夜免费精品视频| 综合欧美一区二区三区| 久久亚洲春色中文字幕久久久| 欧美色图一区二区三区| 白白色 亚洲乱淫| 另类调教123区| 亚洲va欧美va天堂v国产综合| 国产精品美女久久久久久2018| 欧美xxxxxxxxx| 欧美精品日日鲁夜夜添| 色美美综合视频| 国产宾馆实践打屁股91| 极品少妇xxxx精品少妇偷拍 | 色婷婷综合激情| 国产老妇另类xxxxx| 日韩av成人高清| 午夜婷婷国产麻豆精品| 亚洲美女电影在线| 国产精品私人影院| 久久久精品2019中文字幕之3| 欧美一区二区三区四区视频| 欧美亚洲国产一区二区三区va | 亚洲激情在线激情| 国产日韩成人精品| 国产午夜精品理论片a级大结局 | 色综合 综合色| 成人免费视频app| 国产suv一区二区三区88区| 极品少妇一区二区| 激情综合色播五月| 六月丁香婷婷久久| 激情伊人五月天久久综合| 麻豆成人综合网| 蜜臀av性久久久久蜜臀av麻豆 | 亚洲最新在线观看| 夜夜嗨av一区二区三区中文字幕| 夜夜嗨av一区二区三区网页 | 97成人超碰视| 成人午夜电影网站| 成人精品在线视频观看| caoporm超碰国产精品| 色综合色狠狠综合色| 99久精品国产| 欧美日韩在线三区| 91麻豆精品国产91久久久更新时间| 69堂成人精品免费视频| 日韩一级片网址| 久久综合久久综合久久综合| 国产日韩欧美精品一区| 国产精品毛片大码女人| 一区二区成人在线视频| 日产国产欧美视频一区精品| 毛片一区二区三区| 成人一区二区视频| 色欧美片视频在线观看| 欧美日韩一区二区电影| 亚洲精品一区二区在线观看| 国产午夜精品一区二区| 亚洲精品国产第一综合99久久 | 成人免费黄色大片| 色综合久久久久综合体桃花网| 欧美日韩国产首页| 久久综合色鬼综合色| 国产精品美女久久久久aⅴ国产馆| 一区二区三区小说| 精品一区二区三区久久久| 不卡一区二区中文字幕| 91麻豆精品久久久久蜜臀| 26uuuu精品一区二区| 亚洲精品免费一二三区| 精品影视av免费| 成人av在线一区二区三区| 欧美精品精品一区| 日本一区二区三区久久久久久久久不| 亚洲三级免费电影| 毛片av中文字幕一区二区| 91原创在线视频| 欧美精品一区二区三区在线播放| 国产精品伦一区| 日韩精品欧美精品| 97国产精品videossex| 精品国产在天天线2019| 一区二区三区中文字幕电影| 国内精品嫩模私拍在线| 欧美亚洲国产一区二区三区va | 国产精品对白交换视频 | 亚洲激情图片一区| 紧缚捆绑精品一区二区| 欧洲av在线精品| 国产精品久久久久久久第一福利| 日本三级亚洲精品| 在线精品视频免费观看| 亚洲国产精品高清| 麻豆成人免费电影| 欧美色网一区二区| 亚洲人成精品久久久久久| 国产大片一区二区| 欧美一区二区女人| 午夜欧美视频在线观看| 91在线观看一区二区| 久久精品亚洲精品国产欧美kt∨| 欧美aaaaa成人免费观看视频| 色综合久久久久综合体桃花网| 国产欧美综合色| 激情综合色综合久久| 日韩一区二区三区观看| 亚洲va国产va欧美va观看| 色噜噜狠狠色综合中国| 亚洲欧美一区二区视频| 粉嫩av一区二区三区粉嫩| 精品国产免费视频| 另类综合日韩欧美亚洲| 欧美一区二区三区啪啪| 午夜精品在线看| 色狠狠色噜噜噜综合网| 亚洲视频在线一区观看| 成人午夜又粗又硬又大| 国产欧美精品一区| 国产激情精品久久久第一区二区| 欧美大片一区二区三区| 麻豆91免费观看| 日韩一区二区免费电影| 免费欧美在线视频| 日韩一区二区三区在线| 美女视频黄免费的久久| 欧美欧美欧美欧美首页| 婷婷综合五月天| 欧美一区二区视频在线观看| 日韩电影一二三区| 欧美人与禽zozo性伦| 奇米影视一区二区三区小说| 日韩欧美亚洲一区二区| 日韩**一区毛片| 亚洲精品一区二区三区影院| 国产成人综合亚洲网站| 久久精品欧美一区二区三区不卡 | 国产一区二区0| 久久久亚洲精华液精华液精华液| 国产成人综合视频| 国产精品久久777777| 91美女片黄在线| 一区二区国产盗摄色噜噜| 91精品免费观看| 经典三级在线一区| 国产精品护士白丝一区av| 色噜噜狠狠色综合欧洲selulu| 亚洲va欧美va天堂v国产综合| 日韩午夜精品视频| 国产成人h网站| 一区二区在线观看视频| 日韩欧美一区二区久久婷婷| 国产精品一二三区在线| 一区二区不卡在线播放 | 欧美三日本三级三级在线播放|