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

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

?? bitboardimpl.java

?? chess 一個beguanyu國際象棋的一個Java源碼
?? JAVA
字號:
/*  BitBoardImpl - A class, that implements a chess board data structure                  as layered bitmaps.  Copyright (C) 2003 The Java-Chess team <info@java-chess.de>  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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*/ package de.java_chess.javaChess.bitboard;import de.java_chess.javaChess.*;import de.java_chess.javaChess.board.*;import de.java_chess.javaChess.piece.*;import de.java_chess.javaChess.ply.*;import de.java_chess.javaChess.position.*;/** * This class stores a chess board as a couple of * overlayed longs (64-Bit wide). */public class BitBoardImpl implements BitBoard {    // Instance variables    /**     * Store the board in 4 64 bit layers.     * Layer 0 holds the color, layer 1-3 hold the piece code or 0,      * if the square is empty.     */    long [] _boardLayer = new long[4];    // Constructors    /**     * Create a new instance of a chess board with pieces on their     * initial positions.     */    public BitBoardImpl() {	initialPosition();    }    // Methods    /**     * Create a clone of this board.     *     * @return A clone of this board.     */    public final Object clone() {	BitBoardImpl clone = new BitBoardImpl();	for( int i = 0; i < 4; i++) {	    clone._boardLayer[i] = _boardLayer[i];	}	return clone;    }    /**     * Remove all the pieces from the board.     */    public final void emptyBoard() {	for( int i = 0; i < 4; i++) {	    _boardLayer[i] = 0L;	}    }    /**     * Set all the pieces to their initial positions.     */    public final void initialPosition() {	// Empty the board, before the pieces are added.	for( int i = 0; i < 64; i++) {	    setPiece( null, new PositionImpl( i));	}	for( int i = 0; i < 8; i++) {	    setPiece( new PieceImpl( Piece.PAWN, Piece.WHITE), new PositionImpl( 8 + i));	    setPiece( new PieceImpl( Piece.PAWN, Piece.BLACK), new PositionImpl( 48 + i));	}	setPiece( new PieceImpl( Piece.ROOK, Piece.WHITE), new PositionImpl( 0));	setPiece( new PieceImpl( Piece.KNIGHT, Piece.WHITE), new PositionImpl( 1));	setPiece( new PieceImpl( Piece. BISHOP, Piece.WHITE), new PositionImpl( 2));	setPiece( new PieceImpl( Piece.QUEEN, Piece.WHITE), new PositionImpl( 3));	setPiece( new PieceImpl( Piece.KING, Piece.WHITE), new PositionImpl( 4));	setPiece( new PieceImpl( Piece. BISHOP, Piece.WHITE), new PositionImpl( 5));	setPiece( new PieceImpl( Piece.KNIGHT, Piece.WHITE), new PositionImpl( 6));	setPiece( new PieceImpl( Piece.ROOK, Piece.WHITE), new PositionImpl( 7));	setPiece( new PieceImpl( Piece.ROOK, Piece.BLACK), new PositionImpl( 56));	setPiece( new PieceImpl( Piece.KNIGHT, Piece.BLACK), new PositionImpl( 57));	setPiece( new PieceImpl( Piece. BISHOP, Piece.BLACK), new PositionImpl( 58));	setPiece( new PieceImpl( Piece.QUEEN, Piece.BLACK), new PositionImpl( 59));	setPiece( new PieceImpl( Piece.KING, Piece.BLACK), new PositionImpl( 60));	setPiece( new PieceImpl( Piece. BISHOP, Piece.BLACK), new PositionImpl( 61));	setPiece( new PieceImpl( Piece.KNIGHT, Piece.BLACK), new PositionImpl( 62));	setPiece( new PieceImpl( Piece.ROOK, Piece.BLACK), new PositionImpl( 63));    }    /**     * Get the piece of a given position, or null of the square is empty.     *     * @param position The position of the piece.     *      * @return The piece of the square or null, of the square is empty.     */    public final Piece getPiece( Position position) {	int bitpos = position.getSquareIndex();	int pieceType = (((int)(_boardLayer[1] >> bitpos) & 1)			 | (((int)(_boardLayer[2] >> bitpos) & 1) << 1)			 | (((int)(_boardLayer[3] >> bitpos) & 1) << 2));	return (pieceType == 0) ? null : new PieceImpl( (byte)(( pieceType << 1) | (( _boardLayer[0] >> bitpos) & 1)));    }    /**     * Set a piece on a given square.     *     * @param piece The piece to set, or null to empty the square.     * @param position The position of the square.     */    public final void setPiece( Piece piece, Position position) {	byte pieceCodeColor = ((piece == null) ? 0 : piece.getTypeAndColor());	long bitmask = 1L <<  position.getSquareIndex();	long bitFilter = ~bitmask;		for( int i = 0; i < 4; i++) {	    if( ( pieceCodeColor & 1) != 0) {		_boardLayer[i] |= bitmask;  // Set this bit to 1.	    } else {		_boardLayer[i] &= bitFilter;  // Set this bit to 0.	    }	    pieceCodeColor >>= 1;	}    }    /**     * Move a piece from one square to another.     *     * @param ply The ply to perform.     */    public final void doPly( Ply ply) {	Piece movedPiece = getPiece( ply.getSource());	// Check, if it was a castling	if( ply instanceof CastlingPly) {	    int offset = movedPiece.isWhite() ? 0 : 56;	    if( ( (CastlingPly)ply).isLeftCastling()) {		setPiece( movedPiece, new PositionImpl( 2 + offset));		// Move the rook to the right		doPly( new PlyImpl( new PositionImpl( 0 + offset), new PositionImpl( 3 + offset), false));	    } else {		setPiece( movedPiece, new PositionImpl( 6 + offset));		// Move the rook to the left		doPly( new PlyImpl( new PositionImpl( 7 + offset), new PositionImpl( 5 + offset), false));	    }	} else {	    // If a pawn has just reached the last row	    if(ply instanceof TransformationPly) {		// Set a piece of the new type on the destination square.		setPiece( new PieceImpl( ( (TransformationPly)ply).getTypeAfterTransformation(), movedPiece.getColor()), ply.getDestination());	    } else {		// Copy the piece from source square to destination square.		setPiece( movedPiece, ply.getDestination());		// If it's a en passant ply, remove the attacked pawn.		if( ply instanceof EnPassantPly) {		    setPiece( null, ( (EnPassantPly)ply).getAttackedPosition());		}	    }	}	// Empty the source square.	setPiece( null, ply.getSource());    }    /**     * Return a new board, that results from a given ply.     *     * @param ply The ply to perform.     *     * @return A new board with the game position after the ply.     */    public final Board getBoardAfterPly( Ply ply) {	BitBoard newBoard = (BitBoard)clone();	newBoard.doPly( ply);	return newBoard;    }    /**     * Get the positions of some pieces as a long (64 bit wide) bitmask.     *     * @param pieceTypeColor The color and type of the pieces.     */    public final long getPositionOfPieces( int pieceTypeColor) {	return (((pieceTypeColor & 1) != 0 ? _boardLayer[0] : ~_boardLayer[0])		& ((pieceTypeColor & 2) != 0 ? _boardLayer[1] : ~_boardLayer[1])		& ((pieceTypeColor & 4) != 0 ? _boardLayer[2] : ~_boardLayer[2])		& ((pieceTypeColor & 8) != 0 ? _boardLayer[3] : ~_boardLayer[3]));    }    /**     * Get a bitmask with all the free squares.     *     * @return A bitmask with all the empty squares marked by a 1 bit.     */    public final long getEmptySquares() {	return ~( _boardLayer[1] | _boardLayer[2] | _boardLayer[3]);    }    /**     * Get all white or black pieces.     *     * @param white true, if the white pieces are requested,      *              false for the black pieces.     */    public final long getAllPiecesForColor( boolean white) {	return ( ( _boardLayer[1] | _boardLayer[2] | _boardLayer[3]) 		 & ( white ? _boardLayer[0] : ~_boardLayer[0]));    }    /**     * Get the board as a byte stream.     *     * @return The board as a array of bytes.     */    public final byte [] getBytes() {        // A buffer for the bytes.        byte [] buffer = new byte[ 32];	int bufferIndex = 0;	for( int layer = 0; layer < 4; layer++) {	    // Get the current layer.	    long currentLayer = _boardLayer[ layer];	    // Now shift the layer in the buffer.	    for( int bytePos = 0; bytePos < 8; bytePos++) {	        buffer[ bufferIndex++] = (byte)( (int)currentLayer & 0xFF);		currentLayer >>= 8;	    }	}	return buffer;  // Return the buffer with the bytes.    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产视频在线观看一区二区三区| 亚洲成人免费视频| 亚洲少妇最新在线视频| 日韩影院在线观看| 91在线视频免费观看| 精品国产一区二区三区忘忧草| 夜夜夜精品看看| 国产成都精品91一区二区三| 欧美午夜精品一区二区三区| 久久精品视频在线看| 蜜臀a∨国产成人精品| 日本韩国欧美三级| 欧美经典一区二区| 另类欧美日韩国产在线| 欧美日韩国产高清一区二区| 亚洲天堂2016| 国产超碰在线一区| 欧美成人vps| 日精品一区二区| 欧美丝袜丝交足nylons图片| 亚洲丝袜制服诱惑| eeuss鲁片一区二区三区在线观看| 日韩欧美国产麻豆| 亚洲bt欧美bt精品777| 在线观看亚洲a| 亚洲免费电影在线| jlzzjlzz国产精品久久| 欧美激情一区二区在线| 国产不卡一区视频| 国产亚洲欧美中文| 国产精品一线二线三线| 久久久久国产一区二区三区四区 | 18欧美乱大交hd1984| 精品一区二区在线视频| 日韩欧美一级特黄在线播放| 日韩精品久久理论片| 在线成人高清不卡| 日本欧美久久久久免费播放网| 欧美美女一区二区三区| 日韩**一区毛片| 日韩精品一区二区三区在线播放| 免费看欧美美女黄的网站| 日韩欧美色综合| 国产揄拍国内精品对白| 国产人妖乱国产精品人妖| 国产v综合v亚洲欧| 亚洲色欲色欲www在线观看| 91在线视频18| 午夜影视日本亚洲欧洲精品| 日韩一级欧美一级| 国产九色精品成人porny| 欧美激情一区二区三区不卡 | 色哦色哦哦色天天综合| 一区二区三区中文免费| 欧美综合在线视频| 日韩影视精彩在线| 精品久久久三级丝袜| 肉肉av福利一精品导航| 国产精品综合在线视频| 日本大胆欧美人术艺术动态| 欧美白人最猛性xxxxx69交| 精品制服美女丁香| 国产日韩精品一区二区三区在线| 97久久精品人人做人人爽| 一区二区高清在线| 精品国产一区久久| kk眼镜猥琐国模调教系列一区二区| 亚洲欧美影音先锋| 91精品婷婷国产综合久久竹菊| 国产一区91精品张津瑜| 一区二区不卡在线播放| 日韩精品中文字幕在线一区| 不卡av电影在线播放| 视频一区视频二区中文字幕| 国产午夜一区二区三区| 欧美日韩一级片在线观看| 国产成人亚洲精品狼色在线| 亚洲动漫第一页| 久久久国产精品午夜一区ai换脸| 色综合久久天天| 精品中文av资源站在线观看| 亚洲免费av网站| 久久久综合视频| 欧美猛男gaygay网站| 波多野结衣中文一区| 久久99国产乱子伦精品免费| 亚洲精品久久7777| 久久九九99视频| 欧美一区二区福利在线| 色婷婷av久久久久久久| 风流少妇一区二区| 激情综合色播激情啊| 午夜激情一区二区| 亚洲另类春色国产| 中文字幕不卡三区| 久久久三级国产网站| 欧美一区二视频| 欧亚一区二区三区| 色综合久久中文综合久久97 | 国产揄拍国内精品对白| 日韩精品成人一区二区三区| 亚洲精品v日韩精品| 国产精品久久久久久久久免费桃花| 精品国精品自拍自在线| 欧美一区二视频| 欧美一卡二卡在线| 欧美日韩精品专区| 欧美亚洲国产怡红院影院| www.性欧美| 成人黄色av电影| 国产白丝网站精品污在线入口| 蜜桃一区二区三区在线| 日韩av不卡在线观看| 亚洲欧美综合另类在线卡通| 欧美精品丝袜久久久中文字幕| 亚洲一区二区在线视频| 日韩精品最新网址| 欧美日韩黄色影视| 欧美视频三区在线播放| 在线看不卡av| 欧美性淫爽ww久久久久无| 色妹子一区二区| 色网站国产精品| 91成人在线精品| 欧美色视频一区| 91麻豆精品久久久久蜜臀| 在线观看91av| 日韩欧美国产一区在线观看| 日韩免费高清电影| 国产亚洲精久久久久久| 欧美激情一区在线| 亚洲视频一区二区免费在线观看| 亚洲欧美偷拍三级| 亚洲国产另类av| 捆绑调教一区二区三区| 国产久卡久卡久卡久卡视频精品| 懂色av一区二区在线播放| 91免费国产在线| 成人性生交大片免费看在线播放| 成人少妇影院yyyy| 欧美亚洲综合网| 洋洋成人永久网站入口| 自拍偷自拍亚洲精品播放| 一区二区三区欧美| 日韩精品三区四区| 国产一区亚洲一区| 色综合天天狠狠| 日韩欧美在线综合网| 中文字幕高清不卡| 亚洲成人在线免费| 国产一区二区三区久久久 | 欧美v亚洲v综合ⅴ国产v| 精品成人一区二区三区| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 热久久免费视频| 国产成人亚洲精品青草天美| 91电影在线观看| 99久久精品免费看国产免费软件| 国产喂奶挤奶一区二区三区| 欧美浪妇xxxx高跟鞋交| 2020国产精品自拍| 亚洲美女免费在线| 蜜桃av噜噜一区| 色综合久久综合| 欧美成人伊人久久综合网| 国产精品午夜在线观看| 日韩av午夜在线观看| 成人免费高清视频| 欧美一区二区三区视频免费| 国产精品久久久久国产精品日日 | 91黄色在线观看| 久久蜜臀精品av| 日日摸夜夜添夜夜添国产精品| 成人app软件下载大全免费| 日韩午夜小视频| 亚洲卡通动漫在线| 成人免费av网站| 欧美一激情一区二区三区| 一区二区三区在线免费视频| 粉嫩av亚洲一区二区图片| 欧美tickling网站挠脚心| 亚洲国产精品久久艾草纯爱| 成人在线综合网站| 亚洲精品一区在线观看| 国产91丝袜在线播放九色| 国产欧美精品一区| 日韩免费看的电影| 26uuu色噜噜精品一区| 五月婷婷综合在线| 在线精品国精品国产尤物884a| 亚洲国产精品t66y| 紧缚捆绑精品一区二区| 欧美一区二区在线不卡| 香蕉加勒比综合久久| 欧美这里有精品| 成人免费小视频| 99精品视频一区二区三区| 国产肉丝袜一区二区| 国产精品小仙女| 欧美精品一区在线观看|