Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gmail.bernabe.laurent.j2se.chesspresso_test;
- import javax.swing.JFrame;
- import chesspresso.Chess;
- import chesspresso.game.Game;
- import chesspresso.game.view.GameBrowser;
- import chesspresso.move.IllegalMoveException;
- import chesspresso.position.Position;
- public class ChessFrame extends JFrame {
- public ChessFrame(){
- setTitle("Chesspresso gamebrowser test");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- add(gameBrowser);
- pack();
- addMove(Chess.E2, Chess.E4, false, "Debut pour une partie ouverte");
- addMove(Chess.E7, Chess.E5, false, "Reponse symetrique forte");
- addMove(Chess.G1, Chess.F3, false, null);
- addMove(Chess.B8, Chess.C6, false, null);
- addMove(Chess.F1, Chess.A1, false, null);
- }
- private void addMove(int fromSquareIndex, int toSquareIndex,
- boolean isCapturingMove, String comment) {
- Position position = chessGame.getPosition();
- int pieceAtStartSquare = position.getStone(fromSquareIndex);
- short move = position.getPieceMove(pieceAtStartSquare, Chess.sqiToCol(fromSquareIndex),
- Chess.sqiToRow(fromSquareIndex), toSquareIndex);
- try {
- position.doMove(move);
- } catch (IllegalMoveException e) {
- e.printStackTrace();
- }
- }
- private Game chessGame = new Game();
- private GameBrowser gameBrowser = new GameBrowser(chessGame);
- private static final long serialVersionUID = -6856238414376776882L;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement