Advertisement
loloof64

ICTKExperiment

Mar 18th, 2012
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.16 KB | None | 0 0
  1. package com.gmail.bernabe.laurent.j2se.ictk_experiment;
  2.  
  3. import ictk.boardgame.AmbiguousMoveException;
  4. import ictk.boardgame.BoardGameException;
  5. import ictk.boardgame.History;
  6. import ictk.boardgame.IllegalMoveException;
  7. import ictk.boardgame.chess.AmbiguousChessMoveException;
  8. import ictk.boardgame.chess.ChessBoard;
  9. import ictk.boardgame.chess.ChessGame;
  10. import ictk.boardgame.chess.ChessGameInfo;
  11. import ictk.boardgame.chess.ChessMove;
  12. import ictk.boardgame.chess.io.FEN;
  13. import ictk.boardgame.chess.io.SAN;
  14.  
  15. import java.io.IOException;
  16. import java.util.Arrays;
  17.  
  18. public class ICTKExperiment {
  19.  
  20.     public static void main(String[] args) {
  21.         testHistoryFeature();
  22.     }
  23.    
  24.     private static void testHistoryFeature(){
  25.         ChessGame chessGame = new ChessGame();
  26.         ChessBoard chessBoard = (ChessBoard) chessGame.getBoard();
  27.         History chessHistory = chessGame.getHistory();
  28.         try {
  29.             ChessMove move1 = new ChessMove(chessBoard,  5,2,  5,4);
  30.             chessHistory.add(move1, true);
  31.             System.out.println(chessBoard);
  32.             ChessMove move2 = new ChessMove(chessBoard, 5,7,  5,5);
  33.             chessHistory.add(move2, true);
  34.             System.out.println(chessBoard);
  35.             ChessMove move3 = new ChessMove(chessBoard, 7,1,  6,3);
  36.             chessHistory.add(move3, true);
  37.             System.out.println(chessBoard);
  38.             ChessMove move4 = new ChessMove(chessBoard, 2,8,  3,6);
  39.             chessHistory.add(move4, true);
  40.             System.out.println(chessBoard);
  41.             ChessMove move5 = new ChessMove(chessBoard, 6,1,  2,5);
  42.             chessHistory.add(move5, true);
  43.             System.out.println(chessBoard);
  44.             if (chessHistory.hasNext()) {
  45.                 chessHistory.next();
  46.                 System.out.println(chessBoard);
  47.             }
  48.             chessHistory.prev();
  49.             chessHistory.prev();
  50.            
  51.             chessHistory.truncate();
  52.            
  53.             /*
  54.             ChessMove move6 = new ChessMove(chessBoard, 7,8,  6,6);
  55.             chessHistory.add(move6, true);
  56.             System.out.println(chessBoard);
  57.            
  58.             if (chessHistory.hasNext()) {
  59.                 chessHistory.next();
  60.                 System.out.println(chessBoard);
  61.             }
  62.             */
  63.         }
  64.         catch(IllegalMoveException ex){
  65.             ex.printStackTrace();
  66.         } catch (AmbiguousMoveException e) {
  67.             e.printStackTrace();
  68.         } catch (IndexOutOfBoundsException e) {
  69.             e.printStackTrace();
  70.         }
  71.     }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement