Package nl.zoidberg.calculon.engine

Examples of nl.zoidberg.calculon.engine.ChessEngine


  // ------------------------------------- Commands ---------------------------

  private class CommandGo implements Command {

    public void execute(List<String> args) {
            ChessEngine node = new ChessEngine();
           
            String bestMove = node.getPreferredMove(board);
            String pgnMove = PGNUtils.translateMove(board, bestMove);
            send("info pv " + pgnMove);
            send("bestmove " + pgnMove);
    }
View Full Code Here


  public void testTakeHangingPiece() {
    BitBoard board = new BitBoard();
    String fen = "8/1r3k2/8/8/8/8/6K1/RR6 w - - 0 1";
    FENUtils.loadPosition(fen, board);

    ChessEngine node = new ChessEngine();
    String bestMove = node.getPreferredMove(board);
    assertNotNull(bestMove);
    bestMove = PGNUtils.translateMove(board, bestMove);
    assertEquals("Rxb7+", bestMove);
  }
View Full Code Here

  public void testCheckmate() {
    BitBoard board = new BitBoard();
    String fen = "5k2/R7/8/8/8/8/6K1/1R6 w - - 0 1";
    FENUtils.loadPosition(fen, board);

    ChessEngine node = new ChessEngine();
    String bestMove = node.getPreferredMove(board);
   
    assertNotNull(bestMove);
    bestMove = PGNUtils.translateMove(board, bestMove);
    assertEquals("Rb8#", bestMove);
  }
View Full Code Here

    BitBoard board = FENUtils.getBoard("7k/6bp/8/8/8/8/8/1B5K w - - 0 1");
    assertEquals(board.getResult(), Game.RES_NO_RESULT);
   
    // Only sacrificing the bishop for the pawn draws
    assertEquals("Bxh7", PGNUtils.translateMove(board, new ChessEngine().getPreferredMove(board)));
    PGNUtils.applyMove(board, "Bxh7");
    assertEquals(0, new MoveGenerator(board).getAllRemainingMoves().size());
  }
View Full Code Here

   
    bitBoard.makeMove(BitBoard.generateMove(
        BitBoard.coordToPosition("H2"), BitBoard.coordToPosition("H1"), Piece.WHITE, Piece.KING));

    // Now, Kh8 draws against K+Q...
    assertEquals("H8H7", new ChessEngine().getPreferredMove(bitBoard));
    bitBoard.makeMove(BitBoard.generateMove(
        BitBoard.coordToPosition("H8"), BitBoard.coordToPosition("H7"), Piece.BLACK, Piece.KING));
    assertEquals(3, bitBoard.getRepeatedCount());
  }
View Full Code Here

  }
 
  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)));

    // But, now with an extra rook, it's a good idea.. crafty find Rxa5 at depth 11
    bitBoard = FENUtils.getBoard("r5nk/r4ppp/r7/b7/R7/R7/R5PP/R5NK w - - 0 1");
    engine.setQuiesce(true);
//    assertEquals("A4A5", engine.getPreferredMove(bitBoard));
  }
View Full Code Here

//  }
 
    @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

      }
     
      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));
              if(currentBoard != null) {
                PGNUtils.applyMove(currentBoard, bestMove);
View Full Code Here

      }
     
      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) {
              log.info("Moving: " + PGNUtils.translateMove(myBoard, bestMove));
              if(currentBoard != null) {
                currentBoard.makeMove(currentBoard.getMove(bestMove));
View Full Code Here

TOP

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

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.