Package nl.zoidberg.calculon.engine

Examples of nl.zoidberg.calculon.engine.BitBoard


    // A fairly simple mate-in-2
    chessTempoDotComTest("2rr4/5p1k/6pp/8/3QBn2/P4P2/1P3P1q/2RRK3 w - - 3 30", "Qxd8", "Qg1+");
  }
 
  private void chessTempoDotComTest(String fen, String firstMove, String reply) {
    BitBoard bitBoard = FENUtils.getBoard(fen);
    PGNUtils.applyMove(bitBoard, firstMove);
    assertEquals(reply, PGNUtils.translateMove(bitBoard, new ChessEngine().getPreferredMove(bitBoard)));
  }
View Full Code Here


  }
 
    @Test
  public void testQuiesce1() {
    // Taking here is a bad idea... crafty plays Nf3 here...
    BitBoard bitBoard = FENUtils.getBoard("r5nk/r4ppp/r7/b7/8/R7/R5PP/R5NK w - - 0 1");
    ChessEngine engine = new ChessEngine();
        System.out.println(engine.getPreferredMove(bitBoard));
//    engine.setDepth(3);
//    engine.setQuiesce(true);
//    assertFalse("A4A5".equals(engine.getPreferredMove(bitBoard)));
View Full Code Here

//    System.out.println(engine.getPreferredMove(bitBoard));
//  }
 
    @Test
  public void testTactics1() {
    BitBoard bitBoard = FENUtils.getBoard("5rk1/p7/1p2p1q1/2b2p1p/5R1P/1B4P1/P4P2/3Q2K1 w - - 1 32");
    ChessEngine engine = new ChessEngine();
    PGNUtils.applyMove(bitBoard, "Qd7");
    assertEquals("G6G3", engine.getPreferredMove(bitBoard));
  }
View Full Code Here

public class PawnScorerTest {

    @Test
  public void testBasicScore() {
    BitBoard board = new BitBoard().initialise();
    assertEquals(0, new PawnStructureScorer().scorePosition(board));
  }
View Full Code Here

    assertEquals(0, new PawnStructureScorer().scorePosition(board));
  }

    @Test
  public void testIslands() {
    BitBoard board = FENUtils.getBoard("rnbqkbnr/ppp1pppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
    assertEquals(PawnStructureScorer.S_ISLAND, new PawnStructureScorer().scorePosition(board));
   
    board = FENUtils.getBoard("rnbqkbnr/pppppppp/8/8/8/8/PP1PP1PP/RNBQKBNR w KQkq - 0 1");
    assertEquals(-2 * PawnStructureScorer.S_ISLAND, new PawnStructureScorer().scorePosition(board));
  }
View Full Code Here

    assertEquals(-2 * PawnStructureScorer.S_ISLAND, new PawnStructureScorer().scorePosition(board));
  }
 
    @Test
  public void testIsolated() {
    BitBoard board = FENUtils.getBoard("rnbqkbnr/pp1pp1pp/8/8/8/8/P1P1PPPP/RNBQKBNR w KQkq - 0 1");
    assertEquals(-2 * PawnStructureScorer.S_ISOLATED, new PawnStructureScorer().scorePosition(board));
  }
View Full Code Here

  }

    @Test
  public void testDoubled() {
    // Both have islands, only one has doubled
    BitBoard board = FENUtils.getBoard("rnbqkbnr/pp1ppppp/8/8/8/3P4/PP1PPPPP/RNBQKBNR w KQkq - 0 1");
    assertEquals(-PawnStructureScorer.S_DOUBLED, new PawnStructureScorer().scorePosition(board));

    // Here - test pawn gets an advance bonus
    board = FENUtils.getBoard("rnbqkbnr/pp1ppppp/8/8/3P4/3P4/PP1PPPP1/RNBQKBNR w KQkq - 0 1");
    assertEquals(-2 * PawnStructureScorer.S_DOUBLED + 20, new PawnStructureScorer().scorePosition(board));
View Full Code Here

    assertEquals(-2 * PawnStructureScorer.S_DOUBLED + 20, new PawnStructureScorer().scorePosition(board));
  }
 
    @Test
  public void testAdvanced() {
    BitBoard board = FENUtils.getBoard("rnbqkbnr/pppppppp/3P4/8/8/8/PPP1PPPP/RNBQKBNR w KQkq - 0 1");
    assertEquals(200, new PawnStructureScorer().scorePosition(board));

    board = FENUtils.getBoard("rnbqkbnr/ppp1pppp/8/8/8/3p4/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
    assertEquals(-200, new PawnStructureScorer().scorePosition(board));
  }
View Full Code Here

     
      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");
        return;
      }
     
      String bookMove = openingBook.getBookMove(currentBoard);
      if(bookMove != null) {
        PGNUtils.applyMove(currentBoard, bookMove);
        send(bookMove);
        log.fine("Using book move: " + bookMove);
        return;
      }
     
      Runnable moveMaker = new Runnable() {
        public void run() {
          BitBoard myBoard = currentBoard;
          ChessEngine searchNode = new ChessEngine();
          String bestMove = searchNode.getPreferredMove(myBoard);
          if(bestMove != null) {
            if(gameNumber != -1) {
              log.info("Moving: " + PGNUtils.translateMove(myBoard, bestMove));
View Full Code Here

   
    return board;
  }

  public static BitBoard getBoard(String fen) {
    BitBoard board = new BitBoard();
    loadPosition(fen, board);
    return board;
  }
View Full Code Here

TOP

Related Classes of nl.zoidberg.calculon.engine.BitBoard

Copyright © 2018 www.massapicom. 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.