コード例 #1
0
ファイル: Game.java プロジェクト: PadawanBreslau/ZPionka
 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
0
ファイル: Game.java プロジェクト: PadawanBreslau/ZPionka
 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
0
ファイル: Game.java プロジェクト: PadawanBreslau/ZPionka
  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;
  }
コード例 #4
0
ファイル: Game.java プロジェクト: PadawanBreslau/ZPionka
 public Move getLastMove() {
   return m_position.getLastMove();
 }