Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gmail.bernabe.laurent.j2se.ictk_experiment;
- import ictk.boardgame.AmbiguousMoveException;
- import ictk.boardgame.BoardGameException;
- import ictk.boardgame.History;
- import ictk.boardgame.IllegalMoveException;
- import ictk.boardgame.chess.AmbiguousChessMoveException;
- import ictk.boardgame.chess.ChessBoard;
- import ictk.boardgame.chess.ChessGame;
- import ictk.boardgame.chess.ChessGameInfo;
- import ictk.boardgame.chess.ChessMove;
- import ictk.boardgame.chess.io.FEN;
- import ictk.boardgame.chess.io.SAN;
- import java.io.IOException;
- import java.util.Arrays;
- public class ICTKExperiment {
- public static void main(String[] args) {
- testHistoryFeature();
- }
- private static void testHistoryFeature(){
- ChessGame chessGame = new ChessGame();
- ChessBoard chessBoard = (ChessBoard) chessGame.getBoard();
- History chessHistory = chessGame.getHistory();
- try {
- ChessMove move1 = new ChessMove(chessBoard, 5,2, 5,4);
- chessHistory.add(move1, true);
- System.out.println(chessBoard);
- ChessMove move2 = new ChessMove(chessBoard, 5,7, 5,5);
- chessHistory.add(move2, true);
- System.out.println(chessBoard);
- ChessMove move3 = new ChessMove(chessBoard, 7,1, 6,3);
- chessHistory.add(move3, true);
- System.out.println(chessBoard);
- ChessMove move4 = new ChessMove(chessBoard, 2,8, 3,6);
- chessHistory.add(move4, true);
- System.out.println(chessBoard);
- ChessMove move5 = new ChessMove(chessBoard, 6,1, 2,5);
- chessHistory.add(move5, true);
- System.out.println(chessBoard);
- if (chessHistory.hasNext()) {
- chessHistory.next();
- System.out.println(chessBoard);
- }
- chessHistory.prev();
- chessHistory.prev();
- chessHistory.truncate();
- /*
- ChessMove move6 = new ChessMove(chessBoard, 7,8, 6,6);
- chessHistory.add(move6, true);
- System.out.println(chessBoard);
- if (chessHistory.hasNext()) {
- chessHistory.next();
- System.out.println(chessBoard);
- }
- */
- }
- catch(IllegalMoveException ex){
- ex.printStackTrace();
- } catch (AmbiguousMoveException e) {
- e.printStackTrace();
- } catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement