Package com.barrybecker4.game.common

Examples of com.barrybecker4.game.common.MoveList


     */
    private MoveList determineBestMoves(MoveList moveList) {

        int minBest = searchOptions_.getMinBestMoves();
        int percentLessThanBestThresh = searchOptions_.getPercentLessThanBestThresh();
        MoveList bestMoveList;

        if (percentLessThanBestThresh > 0) {
            bestMoveList =
                determineMovesExceedingValueThresh(moveList, minBest, percentLessThanBestThresh);
        }
View Full Code Here


     * @return top moves
     */
    private MoveList determineMovesExceedingValueThresh(MoveList moveList, int minBest, int percentLessThanBestThresh) {

        int numMoves = moveList.size();
        MoveList bestMoveList = new MoveList();
        if (numMoves > 0) {
            Move currentMove = moveList.getFirstMove();
            double thresholdValue = currentMove.getValue() * (1.0  - (float)percentLessThanBestThresh/100.0);
            double sign = thresholdValue < 0 ? -1 :1;

            bestMoveList.add(currentMove);
            int ct = 1;

            while ((sign * currentMove.getValue() >= sign * thresholdValue || ct < minBest) && ct < numMoves) {
                currentMove = moveList.get(ct++);
                bestMoveList.add(currentMove);
            }
        }
        return bestMoveList;
    }
View Full Code Here

     *
     * @return top moves
     */
    private MoveList determineTopPercentMoves(MoveList moveList, int minBest, int topPercent) {
        int numMoves = moveList.size();
        MoveList bestMoveList = moveList;
        int requestedBest = (int) ((float) topPercent / 100.0 * numMoves + 0.5);
        int best = Math.max(minBest, requestedBest);
        if ( best < numMoves)  {
            bestMoveList = moveList.subList(0, best);
        }
View Full Code Here

     * @param lastMove last move that was made on the board
     * @return list of generated moves.
     */
    public MoveList generateMoves(TwoPlayerMove lastMove) {

        MoveList moveList = new MoveList();
        boolean player1 = (lastMove == null) || !lastMove.isPlayer1();

        // There is one path from every piece to every opponent home (i.e. n*NUM_HOMES)
        PathList opponentPaths = board.findAllOpponentShortestPaths(player1);

        List<BoardPosition> pawnLocations = new LinkedList<BoardPosition>();
        for ( int row = 1; row <= board.getNumRows(); row++ ) {
            for ( int col = 1; col <= board.getNumCols(); col++ ) {
                BoardPosition p = board.getPosition( row, col );
                if ( p.isOccupied() && p.getPiece().isOwnedByPlayer1() == player1 ) {
                    pawnLocations.add(p);
                    addMoves( p, moveList, opponentPaths, weights_ );
                }
            }
        }
        if (moveList.isEmpty())
            GameContext.log(1, "There aren't any moves to consider for lastMove=" + lastMove
                    + " Complete movelist =" + board.getMoveList() + " \nThe pieces are at:" + pawnLocations);

        return moveList;
    }
View Full Code Here

     * The computer makes the first move in the game
     */
    @Override
    public void computerMovesFirst() {
        // determine the possible moves and choose one at random.
        MoveList moveList = getSearchable().generateMoves(null, weights_.getPlayer1Weights());

        makeMove( moveList.getRandomMove() );
    }
View Full Code Here

    @Override
    public MoveList generateMoves( TwoPlayerMove lastMove, ParameterArray weights)  {
        getProfiler().startGenerateMoves();

        MoveGenerator generator = new MoveGenerator(weights, getBoard());
        MoveList moveList  = generator.generateMoves(lastMove);

        boolean player1 = (lastMove == null) || !lastMove.isPlayer1();

        MoveList bestMoves =
            bestMoveFinder_.getBestMoves( player1, moveList);

        getProfiler().stopGenerateMoves();
        return bestMoves;
    }
View Full Code Here

     *
     * @return list of urgent moves
     */
    @Override
    public MoveList generateUrgentMoves( TwoPlayerMove lastMove, ParameterArray weights) {
        return new MoveList();
    }
View Full Code Here

    /*
     * generate all possible next moves.
     * impossible for this game.
     */
    public MoveList generateMoves( Move lastMove, ParameterArray weights) {
        return new MoveList();
    }
View Full Code Here

    public final MoveList generateEvaluatedMoves(TwoPlayerMove lastMove, ParameterArray weights) {

        GoProfiler prof = GoProfiler.getInstance();
        prof.startGenerateMoves();

        MoveList moveList = generatePossibleMoves(lastMove);

        for (Move move : moveList)  {
            setMoveValue(weights, (GoMove)move);
        }
        boolean player1 = (lastMove == null) || !lastMove.isPlayer1();
View Full Code Here

     * is difficult without static evaluation. At least no illegal moves will be returned.
     */
    final MoveList generatePossibleMoves(TwoPlayerMove lastMove) {

        GoBoard board = (GoBoard) searchable_.getBoard();
        MoveList moveList = new MoveList();
        int nCols = board.getNumCols();
        int nRows = board.getNumRows();

        CandidateMoveAnalyzer candidateMoves = new CandidateMoveAnalyzer(board);

        boolean player1 = (lastMove == null) || !lastMove.isPlayer1();
        int lastMoveValue = (lastMove== null) ? 0 : lastMove.getValue();

        for (int i = 1; i <= nCols; i++ )  {
            for (int j = 1; j <= nRows; j++ )  {
                // if its a candidate move and not an immediate take-back (which would break the rule of ko)
                if ( candidateMoves.isCandidateMove( j, i ) && !isTakeBack( j, i, (GoMove) lastMove, board ) ) {
                    GoMove m = new GoMove( new ByteLocation(j, i), lastMoveValue, new GoStone(player1) );

                    if ( m.isSuicidal(board) ) {
                        GameContext.log(3, "The move was a suicide (can't add it to the list): " + m);
                    }
                    else {
                        moveList.add( m );
                    }
                }
            }
        }
        return moveList;
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.common.MoveList

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.