Examples of TwoPlayerMove


Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

     * return the SGF (4) representation of the move
     * SGF stands for Smart Game Format and is commonly used for Go
     */
    @Override
    protected String getSgfForMove(Move move) {
        TwoPlayerMove m = (TwoPlayerMove) move;
        // passes are not represented in SGF - so just skip it if the piece is null.

        StringBuilder buf = new StringBuilder("");
        String player = "P2";
        if ( m.isPlayer1() )
        {
            player = "P1";
        }
        buf.append( ';' );
        buf.append( player );
        serializePosition(m.getToLocation(), buf);
        buf.append( '\n' );
        return buf.toString();
    }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

    @Override
    protected TwoPlayerMove findBestMove(TwoPlayerMove lastMove, int depth, MoveList list,
                                         SearchWindow window, SearchTreeNode parent) {
        int i = 0;
        int selectedValue;
        TwoPlayerMove selectedMove;
        // if player 1, then search for a high score, else search for a low score.
        boolean player1 = lastMove.isPlayer1();
        int bestInheritedValue = player1? SearchStrategy.INFINITY: -SearchStrategy.INFINITY;

        TwoPlayerMove bestMove = (TwoPlayerMove)list.get(0);
        while ( !list.isEmpty() ) {
            if (pauseInterrupted())
                return lastMove;

            TwoPlayerMove theMove = getNextMove(list);
            updatePercentDone(depth, list);

            searchable.makeInternalMove( theMove );
            SearchTreeNode child = addNodeToTree(parent, theMove, window); i++;
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

        return searchWithMemory_.getOptions();
    }

    @Override
    public TwoPlayerMove search( TwoPlayerMove lastMove, SearchTreeNode parent ) {
        TwoPlayerMove selectedMove = searchInternal( lastMove, 0, parent);
        return (selectedMove != null) ? selectedMove : lastMove;
    }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

                                          int f, SearchTreeNode parent ) {
        int g = f;
        int upperBound = INFINITY;
        int lowerBound = -INFINITY;

        TwoPlayerMove selectedMove;
        do  {
            int beta = (g == lowerBound) ? g + 1 : g;

            getOptions().getBruteSearchOptions().setInitialSearchWindow(new SearchWindow(beta - 1, beta));
            selectedMove = searchWithMemory_.search(lastMove, parent);
            g = -selectedMove.getInheritedValue();

            if (g < betaupperBound = g;
            else           lowerBound = g;

        } while (lowerBound < upperBound);
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

    @Override
    protected TwoPlayerMove findBestMove(TwoPlayerMove lastMove, int depth, MoveList list,
                                       SearchWindow window, SearchTreeNode parent) {
        int i = 0;
        int bestInheritedValue = -SearchStrategy.INFINITY;
        TwoPlayerMove selectedMove;
        TwoPlayerMove bestMove = (TwoPlayerMove)list.get( 0 );

        while ( !list.isEmpty() ) {
            TwoPlayerMove theMove = getNextMove(list);
            if (pauseInterrupted())
                return lastMove;
            updatePercentDone(depth, list);

            searchable.makeInternalMove( theMove );
            SearchTreeNode child = addNodeToTree(parent, theMove, window); i++;

            selectedMove = searchInternal( theMove, depth-1,
                     new SearchWindow(-window.beta, -Math.max(window.alpha, bestInheritedValue)), child );

            searchable.undoInternalMove( theMove );

            if (selectedMove != null) {
                int selectedValue = -selectedMove.getInheritedValue();
                theMove.setInheritedValue( selectedValue );

                if ( selectedValue > bestInheritedValue ) {
                    bestMove = theMove;
                    bestInheritedValue = selectedValue;
                    if ( alphaBeta_ && bestInheritedValue >= window.beta) {
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

        }
        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.twoplayer.common.TwoPlayerMove

    protected TwoPlayerBoardRenderer()  {}

    @Override
    protected void drawLastMoveMarker(Graphics2D g2, Player player, Board board) {

        TwoPlayerMove last = (TwoPlayerMove) board.getMoveList().getLastMove();
        // this draws a small indicator on the last move to show where it was played
        if ( last != null ) {
            g2.setColor( LAST_MOVE_INDICATOR_COLOR );
            g2.setStroke(LAST_MOVE_INDICATOR_STROKE);
            int cellSize = getCellSize();
            int xpos = getMargin() + (last.getToCol() - 1) * cellSize + 1;
            int ypos = getMargin() + (last.getToRow() - 1) * cellSize + 1;
            g2.drawOval( xpos, ypos, cellSize - 2, cellSize - 2 );
        }
    }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

     * @param attributes list of name values to show.
     */
    public void addPrunedChildNodes( List list, int i, NodeAttributes attributes) {
        int index = i;
        while ( !list.isEmpty() ) {
            TwoPlayerMove theMove = (TwoPlayerMove) (list.remove(0));
            SearchTreeNode child = new SearchTreeNode( theMove, attributes );
            this.insert( child, index );
            index++;
        }
    }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

        if (children == null) return null;
        Enumeration enumeration = children();

        while (enumeration.hasMoreElements()) {
            SearchTreeNode node = (SearchTreeNode)enumeration.nextElement();
            TwoPlayerMove m = (TwoPlayerMove)node.getUserObject();
            if (m.isSelected())
                return node;
        }
        return null;
    }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.common.TwoPlayerMove

        int chainLength = path.getPathCount();
        Object[] nodes = path.getPath();
        SearchTreeNode lastNode = (SearchTreeNode)nodes[chainLength-1];
        List<TwoPlayerMove> moveList = new LinkedList<TwoPlayerMove>();
        TwoPlayerMove m = null;
        for ( int i = 0; i < chainLength; i++ ) {
            SearchTreeNode node = (SearchTreeNode) nodes[i];
            m = (TwoPlayerMove) node.getUserObject();
            if ( m == null )
                return; // no node here
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.