Examples of Style12


Examples of nl.zoidberg.calculon.notation.Style12

    public void message(String s) {
      if (!s.startsWith("<12> ")) {
        return;
      }
     
      final Style12 style12 = new Style12(s);
     
      if(style12.isMyGame()) {
        gameNumber = style12.getGameNumber();
        opponent = style12.getOpponentName();
        if(style12.isInitialPosition()) {
          currentBoard = new BitBoard().initialise();
        }
      }
     
      if ( ! (style12.getMyRelationToGame() == Style12.REL_ME_TO_MOVE)) {
        return;
      }
     
      if(style12.isFlagged()) {
        gameNumber = -1;
        currentBoard = null;
        return;
      }

      if(style12.getHalfMoveCount() >= 100) {
        log.info("Claiming draw by 50-move rule");
        send("draw");
        return;
      }
     
      if(currentBoard != null && !"none".equals(style12.getPreviousMovePGN())) {
        try {
          PGNUtils.applyMove(currentBoard, style12.getPreviousMovePGN());
        } catch (Exception x) {
          log.log(Level.SEVERE, "Apply move failed", x);
        }
      }
     
      if(currentBoard == null || ! currentBoard.getCacheId().equals(style12.getBoard().getCacheId())) {
        log.warning("Out of sync board detected - resetting!");
        currentBoard = style12.getBoard();
      }
     
      if(currentBoard.getRepeatedCount() >= 3) {
        log.info("Claiming draw by 3-fold repitition (opp move)");
        send("draw");
View Full Code Here

Examples of nl.zoidberg.calculon.notation.Style12

    public void message(String s) {
      if (!s.startsWith("<12> ")) {
        return;
      }
     
      final Style12 style12 = new Style12(s);
     
      if(style12.isMyGame()) {
        gameNumber = style12.getGameNumber();
        opponent = style12.getOpponentName();
        playingWhite = (style12.getMyColor() == Piece.WHITE);
        if(style12.isInitialPosition()) {
          currentBoard = new BitBoard().initialise();
        }
      }
     
      if ( ! (style12.getMyRelationToGame() == Style12.REL_ME_TO_MOVE)) {
        return;
      }
     
      if(style12.isFlagged()) {
        gameNumber = -1;
        currentBoard = null;
        return;
      }

      if(style12.getHalfMoveCount() >= 100) {
        log.info("Claiming draw by 50-move rule");
        send("draw");
        return;
      }
     
      if(currentBoard != null && !"none".equals(style12.getPreviousMovePGN())) {
        try {
          currentBoard.makeMove(currentBoard.getMove(PGNUtils.toPgnMoveMap(currentBoard).get(style12.getPreviousMovePGN())));
        } catch (Exception x) {
          log.log(Level.SEVERE, "Apply move failed", x);
        }
      }
     
      if(currentBoard == null || ! currentBoard.equalPosition(style12.getBoard())) {
        log.warning("Out of sync board detected - resetting!");
        currentBoard = style12.getBoard();
      }
     
      if(currentBoard.getRepeatedCount() >= 3) {
        log.info("Claiming draw by 3-fold repitition (opp move)");
        send("draw");
        return;
      }

      String bookMove = openingBook.getBookMove(currentBoard);
      if(bookMove != null) {
        PGNUtils.applyMove(currentBoard, bookMove);
        send(bookMove);
        log.fine("Using book move: " + bookMove);
        return;
      }
     
      if( ! new MoveGenerator(currentBoard).hasNext()) {
        log.fine("Looks like that game is over!");
        return;
      }
     
      Runnable moveMaker = new Runnable() {
        public void run() {
          BitBoard myBoard = currentBoard;
          ChessEngine engine = new ChessEngine();
          if(style12.getGameTime() >= 900) {
            engine.setQuiesce(true);
          }
          String bestMove = engine.getPreferredMove(myBoard);
          if(bestMove != null) {
            if(gameNumber != -1) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.