本文整理匯總了Java中chesspresso.move.IllegalMoveException類的典型用法代碼示例。如果您正苦於以下問題:Java IllegalMoveException類的具體用法?Java IllegalMoveException怎麽用?Java IllegalMoveException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IllegalMoveException類屬於chesspresso.move包,在下文中一共展示了IllegalMoveException類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNextMove
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
public Move getNextMove(int whichLine)
{
short shortMove = m_moves.getMove(m_moves.goForward(m_cur, whichLine));
if (shortMove == GameMoveModel.NO_MOVE) return null; // =====>
try {
m_position.setNotifyListeners(false);
m_position.doMove(shortMove);
// ChMove move = m_position.getLastMove(shortMove);
Move move = m_position.getLastMove();
m_position.undoMove();
m_position.setNotifyListeners(true);
return move;
} catch (IllegalMoveException ex) {
ex.printStackTrace();
return null;
}
}
示例2: getNextMoves
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
public Move[] getNextMoves()
{
m_position.setNotifyListeners(false);
Move[] moves = new Move[m_moves.getNumOfNextMoves(m_cur)];
for (int i=0; i<moves.length; i++) {
short move = m_moves.getMove(m_moves.goForward(m_cur, i));
try {
m_position.doMove(move);
// moves[i] = m_position.getLastMove(move);
moves[i] = m_position.getLastMove();
m_position.undoMove();
} catch (IllegalMoveException ex) {
m_moves.write(System.out);
System.out.println("cur = " + m_cur + " move=" + GameMoveModel.valueToString(move));
ex.printStackTrace();
}
}
m_position.setNotifyListeners(true);
return moves;
}
示例3: goForward
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
private boolean goForward(int whichLine, boolean silent)
{
if (DEBUG) System.out.println("goForward " + whichLine);
int index = m_moves.goForward(m_cur, whichLine);
short shortMove = m_moves.getMove(index);
if (DEBUG) System.out.println(" move = " + Move.getString(shortMove));
if (shortMove != GameMoveModel.NO_MOVE) {
try {
m_cur = index;
m_ignoreNotifications = true;
if (silent) m_position.setNotifyListeners(false);
m_position.doMove(shortMove);
if (silent) m_position.setNotifyListeners(true);
m_ignoreNotifications = false;
return true;
} catch (IllegalMoveException ex) {
ex.printStackTrace();
}
} else {
// new Exception("Forward at end of line").printStackTrace();
}
return false;
}
示例4: goForwardAndGetMove
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
private Move goForwardAndGetMove(int whichLine, boolean silent)
{
if (DEBUG) System.out.println("goForwardAndGetMove " + whichLine);
int index = m_moves.goForward(m_cur, whichLine);
short shortMove = m_moves.getMove(index);
if (DEBUG) System.out.println(" move = " + Move.getString(shortMove));
if (shortMove != GameMoveModel.NO_MOVE) {
try {
m_cur = index;
m_ignoreNotifications = true;
if (silent) m_position.setNotifyListeners(false);
m_position.doMove(shortMove);
Move move = m_position.getLastMove();
if (silent) m_position.setNotifyListeners(true);
m_ignoreNotifications = false;
return move;
} catch (IllegalMoveException ex) {
ex.printStackTrace();
}
} else {
// new Exception("Forward at end of line").printStackTrace();
}
return null;
}
示例5: tryProcessMove
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
private static void tryProcessMove(UserSession userSession, GameInterface g, String command, boolean isWhiteMove) {
try {
NotationParser notationParser = new ChesspressoMoveParser();
MoveParseResult moveParseResult = notationParser.parseMove(g.getBoard().getGame().getPosition(), command, isWhiteMove);
g.getBoard().getGame().getPosition().doMove(moveParseResult.getInternalMove());
} catch(IllegalMoveException e) {
userSession.send(String.format("Illegal move (%s).",command));
System.err.print(e.getMessage());
}
}
示例6: parseMove
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
public MoveParseResult parseMove(Position position, String notation, boolean whiteToMove) throws IllegalMoveException {
short move = (short) this._parseMove(position, notation, whiteToMove);
MoveParseResult moveParseResult = new MoveParseResult();
moveParseResult.input = notation;
moveParseResult.fromSquare = Chess.sqiToStr(Move.getFromSqi(move));
moveParseResult.toSquare = Chess.sqiToStr(Move.getToSqi(move));
// TODO: prettyNotation here
moveParseResult.prettyNotation = "Nf3";
moveParseResult.verboseNotation = ChesspressoUtils.getVerboseNotation(position, move);
moveParseResult.promotionPiece = Character.toString(Chess.pieceToChar(Move.getPromotionPiece(move)));
moveParseResult.setInternalMove(move);
return moveParseResult;
}
示例7: performMove
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
/**
* Used for both chess engine and player moves. Uses Chesspresso's move
* notation. Indexes 0-63 represent the locations on the board.
*
* @param fromIndex
* 0 to 63 position the piece is moving from
* @param toIndex
* 0 to 63 position the piece is moving to
* @param promotion
* if a promotion, the short representation of the piece the pawn
* it turning into. Zero if not a promotion.
* @return all data needed to perform a move on the displayed board, moves
* involve a maximum of two pieces
*/
public ChessPieceMovePair performMove(int fromIndex, int toIndex, short promotion) {
short[] allMoves = mPosition.getAllMoves();
short move = 0;
// find Chesspresso short representation in it's legal moves list
for(short currentMove : allMoves){
if (Move.getFromSqi(currentMove) == fromIndex && Move.getToSqi(currentMove) == toIndex
&& Move.getPromotionPiece(currentMove) == promotion) {
move = currentMove;
break;
}
}
ChessPieceMovePair movePair = new ChessPieceMovePair(move, Position.isWhiteToPlay(mPosition.getHashCode()));
// Chesspresso state update
try {
mPosition.doMove(move);
} catch (IllegalMoveException e) {
e.printStackTrace();
}
mOverlay.getMoveHistory().addMove(movePair.getPrimary());
mOverlay.getCheckmateDialog().setState(mPosition.isMate(), mPosition.isCheck());
return movePair;
}
示例8: dragged
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
public void dragged(ImmutablePosition position, int from, int to, MouseEvent e)
{
try {
m_game.getPosition().doMove(m_game.getPosition().getMove(from, to, Chess.NO_PIECE));
} catch (IllegalMoveException ex) {
ex.printStackTrace();
// games should only contain legal moves, so there must
// be a bug somewhere
}
}
示例9: doMove
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
public void doMove(Move move) throws IllegalMoveException
{
doMove(move.getShortMoveDesc());
}
示例10: parseMove
import chesspresso.move.IllegalMoveException; //導入依賴的package包/類
public MoveParseResult parseMove(Position position, String notation, boolean whiteToMove) throws IllegalMoveException;