Package nl.zoidberg.calculon.engine

Examples of nl.zoidberg.calculon.engine.MoveGenerator


    @Test
  public void threeRepeatDrawDetect1() {
    BitBoard bitBoard = new BitBoard().initialise();
   
    PGNUtils.applyMoves(bitBoard, new String[] { "Nf3", "Nf6", "Ng1", "Ng8", "Nf3", "Nf6", "Ng1", });
    assertEquals(22, new MoveGenerator(bitBoard).getAllRemainingMoves().size());
   
    PGNUtils.applyMove(bitBoard, "Ng8");
    assertEquals(0, new MoveGenerator(bitBoard).getAllRemainingMoves().size());
  }
View Full Code Here


  }
 
    @Test
  public void knightMoves() {
    BitBoard board = FENUtils.getBoard("7k/8/8/8/8/8/7P/7K w - - 0 1");
    int baseMoves = new MoveGenerator(board).getAllRemainingMoves().size();
   
    board = FENUtils.getBoard("7k/8/8/8/3N4/8/7P/7K w - - 0 1");
    assertEquals(baseMoves + 8, new MoveGenerator(board).getAllRemainingMoves().size());

    board = FENUtils.getBoard("7k/8/8/8/8/8/7P/N6K w - - 0 1");
    assertEquals(baseMoves + 2, new MoveGenerator(board).getAllRemainingMoves().size());
  }
View Full Code Here

    }
  }

  private int generateToDepth(int depth, BitBoard bitBoard) {
    if(depth == 1) {
            return new MoveGenerator(bitBoard).getAllRemainingMoves().size();
    }

        int count = 0;
    for(Iterator<BitBoardMove> moveItr = new MoveGenerator(bitBoard); moveItr.hasNext(); ) {
      BitBoardMove move = moveItr.next();
      byte x = bitBoard.getFlags();
      long cs = bitBoard.getChecksum();
      bitBoard.makeMove(move);
      count += generateToDepth(depth-1, bitBoard);
      bitBoard.unmakeMove();
View Full Code Here

    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

      applyMove(bitBoard, s);
    }
  }
 
  public static Map<String, String> toPgnMoveMap(BitBoard bitBoard) {
    List<BitBoardMove> allMoves = new MoveGenerator(bitBoard).getAllRemainingMoves();
    Map<String, String> rv = new HashMap<String, String>();
   
    for(BitBoardMove intMove: allMoves) {
      rv.put(translateMove(bitBoard, intMove.getAlgebraic()), intMove.getAlgebraic());
    }
View Full Code Here

      break;
    }

    if (testClash) {
      String fromSquare = simpleAlgebraic.substring(0, 2);
      List<BitBoardMove> m = new MoveGenerator(bitBoard).getAllRemainingMoves();
      List<String> clashingPieces = new ArrayList<String>();
      for (BitBoardMove key : m) {
        if (key.getAlgebraic().startsWith("O-")) {
          continue;
        }
View Full Code Here

        System.out.println(", status = " + (rc.count == 115196793 ? "OK" : "Error! " + rc.count));
  }

  private static void generateToDepth(int depth, BitBoard board, RunningCount runningCount) {
    if(depth == 1) {
      List<BitBoardMove> allMoves = new MoveGenerator(board).getAllRemainingMoves();
      runningCount.count += allMoves.size();
      return;
    }
    for(BitBoardMove move: new MoveGenerator(board).getAllRemainingMoves()) {
      board.makeMove(move);
      generateToDepth(depth-1, board, runningCount);
      board.unmakeMove();
    }
  }
View Full Code Here

        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() {
View Full Code Here

        BitBoard board = new BitBoard().initialise();

        // Min 1350
        long pre = System.nanoTime();
        for(int x = 0; x < 1000000; x++) {
            MoveGenerator moveGenerator = new MoveGenerator(board);
            moveGenerator.setGenerators(new PawnMoveGenerator());
            moveGenerator.getAllRemainingMoves();
        }
        pre = System.nanoTime() - pre;
        System.out.println("time(ms): " + pre/1000000);
    }
View Full Code Here

     
      if(depth >= 0) {
        return alpha;
      }
  
      for(BitBoardMove move: new MoveGenerator(bitBoard).getThreateningMoves()) {
        System.out.println("Q:" + move.getAlgebraic());
        bitBoard.makeMove(move);
          int score = -quiesce(bitBoard, -beta, -alpha, depth++);
        bitBoard.unmakeMove();
  
View Full Code Here

TOP

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

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.