Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.loloof64.j2se.cling_chess_exp;
- public class ChessMove {
- public int startFile, startRank, endFile, endRank;
- public ChessMove(){
- }
- public ChessMove(int startFile, int startRank, int endFile, int endRank) {
- this.startFile = startFile;
- this.startRank = startRank;
- this.endFile = endFile;
- this.endRank = endRank;
- }
- public int packValue(){
- return startFile << 24 | startRank << 16 | endFile << 8 | endRank;
- }
- public static ChessMove unpack(int packedValue){
- int eRank = packedValue & 0xFF;
- packedValue >>= 8;
- int eFile = packedValue & 0xFF;
- packedValue >>= 8;
- int sRank = packedValue & 0xFF;
- packedValue >>= 8;
- int sFile = packedValue;
- return new ChessMove(sFile, sRank, eFile, eRank);
- }
- public String toString(){
- return String.format("ChessMove[%d %d %d %d]", startFile, startRank, endFile, endRank);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement