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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? position.java

?? J2ME編寫的完整國際象棋程序
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
/*
Position.java - Source Code for Mobile Chess, Part I

Mobile Chess - a Chess Program for Java ME
Designed by Morning Yellow, Version: 1.05, Last Modified: Mar. 2008
Copyright (C) 2004-2008 www.elephantbase.net

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package chess;

import java.io.InputStream;
import java.io.PrintStream;
import java.util.Random;

public class Position {
	/*
	public static void __ASSERT(boolean cond) {
		if (!cond) {
			throw new RuntimeException();
		}
	}
	*/

	public static final int MATE_VALUE = 10000;
	public static final int WIN_VALUE = MATE_VALUE - 100;
	public static final int NULL_SAFE_MARGIN = 1000;
	public static final int NULL_OKAY_MARGIN = 500;
	public static final int DRAW_VALUE = 50;
	public static final int ADVANCED_VALUE = 10;

	public static final int MAX_MOVE_NUM = 256;
	public static final int MAX_GEN_MOVES = 128;
	public static final int MAX_BOOK_SIZE = 16384;

	public static final int PIECE_KING = 0;
	public static final int PIECE_QUEEN = 1;
	public static final int PIECE_ROOK = 2;
	public static final int PIECE_BISHOP = 3;
	public static final int PIECE_KNIGHT = 4;
	public static final int PIECE_PAWN = 5;

	public static final int DIFF_LINE = 0;
	public static final int SAME_RANK = 1;
	public static final int SAME_FILE = 2;
	public static final int SAME_DIAG_A1H8 = 3;
	public static final int SAME_DIAG_A8H1 = 4;

	public static final int RANK_TOP = 0;
	public static final int RANK_BOTTOM = 7;
	public static final int FILE_LEFT = 4;
	public static final int FILE_RIGHT = 11;

	public static final byte[] LEGAL_SPAN = new byte[] {
							 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 2, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 2, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0,
	};

	public static final byte[] SAME_LINE = new byte[] {
							 0, 0, 0, 0, 0, 0, 0, 0, 0,
		4, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0,
		0, 4, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 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, 1, 0, 0, 0, 0,
		0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0,
	};

	public static final int[] KING_DELTA = {-17, -16, -15, -1, 1, 15, 16, 17};
	public static final int[] ROOK_DELTA = {-16, -1, 1, 16};
	public static final int[] BISHOP_DELTA = {-17, -15, 15, 17};
	public static final int[] KNIGHT_DELTA = {-33, -31, -18, -14, 14, 18, 31, 33};
	public static final int[] MMV_VALUE = {0, 900, 500, 300, 300, 100};
	public static final int[] CASTLING_DIRECTION = {1, -1, 1, -1};
	public static final int[] CASTLING_KING_SRC = {0x78, 0x78, 0x08, 0x08};
	public static final int[] CASTLING_ROOK_DST = {0x79, 0x77, 0x09, 0x07};
	public static final int[] CASTLING_KING_DST = {0x7a, 0x76, 0x0a, 0x06};
	public static final int[] CASTLING_ROOK_SRC = {0x7b, 0x74, 0x0b, 0x04};

	public static final String PIECE_STRING = "KQRBNP";

	public static final String[] STARTUP_FEN = {
		"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
		"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/R1BQKBNR w KQkq - 0 1",
		"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/1NBQKBNR w KQkq - 0 1",
		"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNB1KBNR w KQkq - 0 1",
	};

	public static boolean IN_BOARD(int sq) {
		return ((sq - 4) & 0x88) == 0;
	}

	public static int RANK_Y(int sq) {
		return sq >> 4;
	}

	public static int FILE_X(int sq) {
		return sq & 15;
	}

	public static int COORD_XY(int x, int y) {
		return x + (y << 4);
	}

	public static int SQUARE_FLIP(int sq) {
		return 127 - sq;
	}

	public static int SQUARE_FORWARD(int sq, int sd) {
		return sq - 16 + (sd << 5);
	}

	public static int FORWARD_DELTA(int sd) {
		return (sd << 5) - 16;
	}

	public static boolean PAWN_INIT(int sq, int sd) {
		return PAWN_LINE[sq] == sd + 1;
	}

	public static boolean PAWN_PROMOTION(int sq, int sd) {
		return PAWN_LINE[sq] == sd + 3;
	}

	public static boolean PAWN_EN_PASSANT(int sq, int sd) {
		return PAWN_LINE[sq] == sd + 5;
	}

	public static boolean KING_SPAN(int sqSrc, int sqDst) {
		return LEGAL_SPAN[sqDst - sqSrc + 128] == 1;
	}

	public static boolean KNIGHT_SPAN(int sqSrc, int sqDst) {
		return LEGAL_SPAN[sqDst - sqSrc + 128] == 2;
	}

	public static int SAME_LINE(int sqSrc, int sqDst) {
		return SAME_LINE[sqDst - sqSrc + 128];
	}

	public static int CASTLING_TYPE(int sd, int sqSrc, int sqDst) {
		return (sd << 1) + (sqDst > sqSrc ? 0 : 1);
	}

	public static int SIDE_TAG(int sd) {
		return 8 + (sd << 3);
	}

	public static int OPP_SIDE_TAG(int sd) {
		return 16 - (sd << 3);
	}

	public static int SRC(int mv) {
		return mv & 127;
	}

	public static int DST(int mv) {
		return mv >> 7;
	}

	public static int MOVE(int sqSrc, int sqDst) {
		return sqSrc + (sqDst << 7);
	}

	public static int PIECE_TYPE(int pc) {
		return pc & 7;
	}

	public static int MVV_LVA(int pc, int lva) {
		return MMV_VALUE[PIECE_TYPE(pc)] - lva;
	}

	public static int PARSE_COORD(String str, int index) {
		int sq = 0;
		if (index == str.length()) {
			return 0;
		}
		int c = str.charAt(index);
		if (c >= 'a' && c <= 'h') {
			if (index + 1 == str.length()) {
				return 0;
			}
			char c2 = str.charAt(index + 1);
			if (c2 >= '1' && c2 <= '8') {
				sq = COORD_XY(c - 'a' + FILE_LEFT, '8' - c2 + RANK_TOP);
			}
		}
		return sq;
	}

	public static int PARSE_MOVE(String str) {
		return PARSE_MOVE(str, 0);
	}

	public static int PARSE_MOVE(String str, int index) {
		return MOVE(PARSE_COORD(str, index), PARSE_COORD(str, index + 2));
	}

	public static String SQUARE_STR(int sq) {
		return "" + (char) ('a' + FILE_X(sq) - FILE_LEFT) + (char) ('8' - RANK_Y(sq) + RANK_TOP);
	}

	public static String MOVE_STR(int mv) {
		return SQUARE_STR(SRC(mv)) + SQUARE_STR(DST(mv));
	}

	public static int PreGen_zobristKeyPlayer;
	public static int PreGen_zobristLockPlayer;
	public static int[][] PreGen_zobristKeyTable = new int[12][128];
	public static int[][] PreGen_zobristLockTable = new int[12][128];

	public static Random random = new Random();

	public static int bookSize = 0;
	public static int[] bookLock = new int[MAX_BOOK_SIZE];
	public static short[] bookMove = new short[MAX_BOOK_SIZE];
	public static short[] bookValue = new short[MAX_BOOK_SIZE];

	static {
		Util.RC4 rc4 = new Util.RC4(new byte[] {0});
		PreGen_zobristKeyPlayer = rc4.nextLong();
		rc4.nextLong(); // Skip ZobristLock0
		PreGen_zobristLockPlayer = rc4.nextLong();
		for (int i = 0; i < 12; i ++) {
			for (int j = 0; j < 128; j ++) {
				PreGen_zobristKeyTable[i][j] = rc4.nextLong();
				rc4.nextLong(); // Skip ZobristLock0
				PreGen_zobristLockTable[i][j] = rc4.nextLong();
			}
		}

		InputStream in = rc4.getClass().getResourceAsStream("/book/BOOK.DAT");
		if (in != null) {
			try {
				while (bookSize < MAX_BOOK_SIZE) {
					bookLock[bookSize] = Util.readInt(in) >>> 1;
					bookMove[bookSize] = (short) Util.readShort(in);
					bookValue[bookSize] = (short) Util.readShort(in);
					bookSize ++;
				}
			} catch (Exception e) {
				// Exit "while" when IOException occurs
			}
			try {
				in.close();
			} catch (Exception e) {
				throw new RuntimeException(e.getMessage());
			}
		}
	}

	public int sdPlayer;
	public byte[] squares = new byte[128];

	public int zobristKey;
	public int zobristLock;
	public int vlWhite, vlBlack;
	public int moveNum, distance;

	public int[] mvList = new int[MAX_MOVE_NUM];
	public int[] pcList = new int[MAX_MOVE_NUM];
	public int[] keyList = new int[MAX_MOVE_NUM];
	public boolean[] chkList = new boolean[MAX_MOVE_NUM];
	public boolean[] specialMoveList = new boolean[MAX_MOVE_NUM];
	public int[] castlingBitsList = new int[MAX_MOVE_NUM];
	public int[] sqEnPassantList = new int[MAX_MOVE_NUM];

	public int[] brWhitePawn = new int[8]; // br = Bit-Rank
	public int[] brBlackPawn = new int[8]; // br = Bit-Rank
	public short[][] vlWhitePiecePos = new short[6][128];
	public short[][] vlBlackPiecePos = new short[6][128];

	public void clearBoard() {
		sdPlayer = 0;
		for (int sq = 0; sq < 128; sq ++) {
			squares[sq] = 0;
		}
		for (int i = 0; i < 8; i ++) {
			brWhitePawn[i] = brBlackPawn[i] = 0;
		}
		zobristKey = zobristLock = 0;
		vlWhite = vlBlack = 0;
	}

	public boolean captured() {
		return pcList[moveNum - 1] > 0;
	}

	public boolean inCheck() {
		return chkList[moveNum - 1];
	}

	public boolean specialMove() {
		return specialMoveList[moveNum - 1];
	}

	public int castlingBits() {
		return castlingBitsList[moveNum - 1];
	}

	public int enPassantSquare() {
		return sqEnPassantList[moveNum - 1];
	}

	public boolean canCastling(int castling) {
		if (!inCheck() && (castlingBits() & (1 << castling)) != 0) {
			int delta = CASTLING_DIRECTION[castling];
			int sqSrc = CASTLING_KING_SRC[castling] + delta;
			int sqDst = CASTLING_ROOK_SRC[castling];
			while (sqSrc != sqDst) {
				if (squares[sqSrc] > 0) {
					return false;
				}
				sqSrc += delta;
			}
			return !checked(CASTLING_ROOK_DST[castling]);
		}
		return false;
	}

	public void setIrrev() {
		setIrrev(castlingBits(), enPassantSquare());
	}

	public void setIrrev(int castlingBits, int sqEnPassant) {
		mvList[0] = pcList[0] = 0;
		castlingBitsList[0] = castlingBits;
		sqEnPassantList[0] = sqEnPassant;
		chkList[0] = checked();
		moveNum = 1;
		distance = 0;
	}

	public void addPiece(int sq, int pc, boolean del) {
		int pcAdjust;
		squares[sq] = (byte) (del ? 0 : pc);
		if (pc < 16) {
			if (pc == 8 + PIECE_PAWN) {
				brWhitePawn[RANK_Y(sq)] ^= 1 << FILE_X(sq);
			}
			pcAdjust = pc - 8;
			vlWhite += del ? -vlWhitePiecePos[pcAdjust][sq] : vlWhitePiecePos[pcAdjust][sq];
		} else {
			if (pc == 16 + PIECE_PAWN) {
				brBlackPawn[RANK_Y(sq)] ^= 1 << FILE_X(sq);
			}
			pcAdjust = pc - 16;
			vlBlack += del ? -vlBlackPiecePos[pcAdjust][sq] : vlBlackPiecePos[pcAdjust][sq];
			pcAdjust += 6;
		}
		zobristKey ^= PreGen_zobristKeyTable[pcAdjust][sq];
		zobristLock ^= PreGen_zobristLockTable[pcAdjust][sq];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久这里只有精品视频网| 国产欧美日韩精品一区| 一区二区三区美女视频| 日本精品一区二区三区四区的功能| 久久久久久久综合色一本| 一本大道av伊人久久综合| 久久看人人爽人人| 成人亚洲精品久久久久软件| 国产精品成人一区二区艾草 | 成人网页在线观看| 国产精品色婷婷| 99这里都是精品| 一区二区三区在线不卡| 69久久99精品久久久久婷婷| youjizz久久| 日韩欧美三级在线| www.欧美亚洲| 极品销魂美女一区二区三区| 亚洲人亚洲人成电影网站色| 精品国产伦一区二区三区观看体验 | 欧美日韩国产首页在线观看| 亚洲高清免费观看高清完整版在线观看| 欧美日韩久久久| 经典三级一区二区| 亚洲天堂精品视频| 亚洲精品在线三区| 99麻豆久久久国产精品免费| 午夜精品福利久久久| 欧美激情中文字幕| 91精品视频网| 91黄色激情网站| 国产91精品免费| 激情综合色综合久久| 一区二区三区 在线观看视频| 欧美v亚洲v综合ⅴ国产v| 日本高清免费不卡视频| 国产精品1024久久| 日韩中文字幕不卡| 亚洲免费观看高清在线观看| 久久久久久久久久久久久久久99| 欧美色中文字幕| 99精品欧美一区二区三区小说 | 欧美日韩电影一区| 欧美日高清视频| 在线观看成人免费视频| 99天天综合性| 色诱视频网站一区| 91农村精品一区二区在线| 韩国精品主播一区二区在线观看 | 国产丝袜美腿一区二区三区| 欧美成人aa大片| 精品久久人人做人人爱| 精品久久国产97色综合| 337p日本欧洲亚洲大胆色噜噜| 欧美一级一区二区| 久久嫩草精品久久久久| 国产欧美日韩综合精品一区二区| 久久综合av免费| 中文字幕第一页久久| 夜夜夜精品看看| 奇米综合一区二区三区精品视频| 久久疯狂做爰流白浆xx| 经典三级一区二区| 91蜜桃在线免费视频| 色婷婷国产精品综合在线观看| 欧美日韩在线播放三区| 欧美一级欧美三级| 中文字幕一区三区| 午夜一区二区三区视频| 日本午夜精品视频在线观看| 激情综合网最新| 色婷婷综合久色| 日韩欧美中文一区| 亚洲欧美激情插| 国内成人精品2018免费看| 99视频在线精品| 26uuu国产一区二区三区| 亚洲视频每日更新| 欧美日韩国产精品自在自线| 日韩欧美国产综合| 一区二区三区在线观看视频| 久久国产尿小便嘘嘘| 欧美性一二三区| 亚洲国产高清aⅴ视频| 日韩福利视频导航| 色综合天天综合狠狠| 日本一区二区三区高清不卡 | 国产精品久久毛片| 国产在线播放一区二区三区| 欧美精选午夜久久久乱码6080| 中文字幕亚洲一区二区va在线| 狠狠色丁香婷婷综合| 欧美日韩精品欧美日韩精品一综合| 国产精品久久久久一区| 国产成人亚洲综合a∨猫咪| 精品美女一区二区| 狠狠色综合播放一区二区| 日韩欧美亚洲另类制服综合在线| 亚洲一区欧美一区| 欧美在线免费播放| 亚洲综合色视频| 欧美日韩mp4| 奇米精品一区二区三区在线观看 | 久久99精品久久久久久久久久久久| 欧美三级电影在线观看| 亚洲国产裸拍裸体视频在线观看乱了| 91亚洲精品一区二区乱码| 亚洲激情欧美激情| 在线成人av网站| 久久99国产精品免费网站| 久久日韩粉嫩一区二区三区| 成人性生交大片| 亚洲综合999| 久久久久久久免费视频了| youjizz久久| 老司机精品视频线观看86| 亚洲精品一线二线三线| 中文字幕一区二区三区蜜月 | 亚洲图片有声小说| 国产精品免费久久久久| 97久久超碰国产精品电影| 亚洲一区二区三区在线播放| 91精品国产91久久久久久一区二区 | 午夜精品福利一区二区蜜股av| 欧美xxxx老人做受| 91久久免费观看| 日韩欧美高清在线| 99国产精品久久久久久久久久| 亚洲男人的天堂在线aⅴ视频| 成人在线视频一区| 亚洲狠狠丁香婷婷综合久久久| 日本不卡视频一二三区| 国产免费久久精品| 成人国产一区二区三区精品| 国产日韩欧美一区二区三区综合| 成人性色生活片免费看爆迷你毛片| 亚洲成国产人片在线观看| 国产精品美女久久久久久久| 亚洲va欧美va国产va天堂影院| 成人免费看的视频| 精品国产1区2区3区| 天天做天天摸天天爽国产一区| 99久久精品情趣| 日韩欧美色综合| 国产网红主播福利一区二区| 北条麻妃国产九九精品视频| 人人精品人人爱| 国产精品高潮久久久久无| 7777精品伊人久久久大香线蕉经典版下载 | 亚洲3atv精品一区二区三区| 日韩欧美国产一区二区三区 | 精品无人码麻豆乱码1区2区| 亚洲一区二区在线免费看| 亚洲欧洲国产日韩| 国产精品色婷婷久久58| 日本一区二区免费在线观看视频| 中文字幕在线不卡国产视频| 国产欧美日韩在线看| 国产精品午夜在线| 一区二区三区在线视频观看58| 亚洲精品国产一区二区精华液| 亚洲一区二区三区中文字幕在线 | 欧美日本在线一区| 2017欧美狠狠色| 亚洲狼人国产精品| 寂寞少妇一区二区三区| 国产美女视频一区| 色嗨嗨av一区二区三区| 欧美探花视频资源| 久久久久久久综合狠狠综合| 国产欧美日本一区视频| 亚洲一区成人在线| 国产成人av影院| 欧美日韩日本视频| 国产精品污网站| 另类小说一区二区三区| 在线观看av一区二区| 精品久久一区二区| 亚洲国产日韩a在线播放| 成人深夜在线观看| 日韩欧美一卡二卡| 亚洲国产一区视频| www.一区二区| 国产亚洲欧美在线| 日本欧美一区二区三区乱码| 色综合久久综合中文综合网| 国产欧美日韩在线观看| 成人免费在线播放视频| 大尺度一区二区| 亚洲啪啪综合av一区二区三区| 色老汉一区二区三区| 香蕉影视欧美成人| 久久久久久9999| 色网综合在线观看| 麻豆精品视频在线观看免费 | 亚洲一级不卡视频| 精品日本一线二线三线不卡| 午夜精品久久一牛影视| 欧美日韩国产精品成人| 婷婷六月综合亚洲|