Examples of MoveList


Examples of com.barrybecker4.game.common.MoveList

    @Override
    public void addPrunedNodes(final MoveList list, final SearchTreeNode parent,
                               final int i, final NodeAttributes attributes) {
        synchronized (root_) {
            // make a defensive copy of the list because we may modify it.
            final MoveList listCopy = new MoveList(list);
            parent.addPrunedChildNodes(listCopy, i, attributes);
        }
    }
View Full Code Here

Examples of com.barrybecker4.game.common.MoveList

            entry = new Entry(lastMove, -lastMove.getInheritedValue());
            lookupTable.put(key, entry);
            return lastMove;
        }

        MoveList list = searchable.generateMoves(lastMove, weights_);

        if (depth == lookAhead_)
            numTopLevelMoves_ = list.size();

        if ( emptyMoveList(list, lastMove) )  return null;

        return findBestMove(lastMove, depth, list, window, parent);
    }
View Full Code Here

Examples of com.barrybecker4.game.common.MoveList

            entry.upperValue = value;
            lookupTable.put(key, entry);
            return lastMove;
        }

        MoveList list = searchable.generateMoves(lastMove, weights_);

        if (depth == lookAhead_)
            numTopLevelMoves_ = list.size();

        if ( emptyMoveList( list, lastMove) )   return null;

        return findBestMove(lastMove, depth, list, window, parent);
    }
View Full Code Here

Examples of com.barrybecker4.game.common.MoveList

        if (numRandMoves >= numRandomLookAhead || searchable.done(lastMove, false)) {
            int score = searchable.worth(lastMove, weights_);
            lastMove.setValue(score);
            return WinProbabilityCaclulator.getChanceOfPlayer1Winning(score);
        }
        MoveList moves = searchable.generateMoves(lastMove, weights_);
        if (moves.size() == 0) {
            return WinProbabilityCaclulator.getChanceOfPlayer1Winning(lastMove.getValue());
        }
        TwoPlayerMove randomMove = (TwoPlayerMove) moves.getRandomMoveForThresh(percentLessThanBestThresh);

        searchable.makeInternalMove(randomMove);
        return playRandomMove(randomMove, searchable, startNumMoves);
    }
View Full Code Here

Examples of com.barrybecker4.game.common.MoveList

                return lastMove;
            }
        }

        // generate a list of all (or bestPercent) candidate next moves, and pick the best one
        MoveList list = searchable.generateMoves(lastMove,  weights_);

        if (depth == lookAhead_)
            numTopLevelMoves_ = list.size();

        if (emptyMoveList(list, lastMove)) {
            updatePercentDone(depth, list);
            // if there are no possible next moves, return null (we hit the end of the game).
            return null;
View Full Code Here

Examples of com.barrybecker4.game.common.MoveList

     * @return best quiescent move
     */
    TwoPlayerMove quiescentSearch(TwoPlayerMove lastMove,
                                  int depth, SearchWindow window, SearchTreeNode parent) {

        MoveList urgentMoves = searchable.generateUrgentMoves(lastMove, weights_);
        if (emptyMoveList(urgentMoves, lastMove)) return null;

        return findBestMove(lastMove, depth, urgentMoves, window, parent);
    }
View Full Code Here

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

Examples of com.barrybecker4.game.common.MoveList

     * @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

Examples of com.barrybecker4.game.common.MoveList

     *
     * @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

Examples of com.barrybecker4.game.common.MoveList

     * @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
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.