Package com.barrybecker4.game.twoplayer.go.board.elements.position

Examples of com.barrybecker4.game.twoplayer.go.board.elements.position.GoBoardPosition


     * later we look for empty spots that are true for candidate moves
     */
    private void determineAdjacentCandidates() {
        for (int i = 1; i <= size_; i++ ) {
            for (int j = 1; j <= size_; j++ ) {
                GoBoardPosition pos = (GoBoardPosition) board_.getPosition(i,j);
                if ( pos.isOccupied() ) {
                    addCandidateMoves(pos);
                }
            }
        }
    }
View Full Code Here


        int startcol = Math.max( stone.getCol() - CANDIDATE_MOVE_OFFSET, 1 );
        int stopcol = Math.min( stone.getCol() + CANDIDATE_MOVE_OFFSET, size_ );
        // set the footprint
        for (int i = startrow; i <= stoprow; i++ ) {
            for (int j = startcol; j <= stopcol; j++ )  {
                GoBoardPosition pos = (GoBoardPosition) board_.getPosition(i,j);
                 tryToAddCandidateMove(pos);
            }
        }
    }
View Full Code Here

     * Add only if unoccupied and not an unconditionally alive eye.
     * never add a stone from either side to an unconditionally alive eye. There is no advantage to it.
     * @param position the position to try adding as a possible candidate move.
     */
    private void tryToAddCandidateMove(BoardPosition position) {
        GoBoardPosition pos = (GoBoardPosition) position;

        if (pos.isUnoccupied() && !(pos.getEye() != null && pos.getEye().isUnconditionallyAlive())) {
            candidateMoves_[pos.getRow()][pos.getCol()] = true;
        }
    }
View Full Code Here

     *
     * @return true of the enemy piece on the diagonal is relatively strong and there are group stones adjacent.
     */
    private boolean qualifiedOpponentDiagonal(int rowOffset, int colOffset, int r, int c, boolean groupP1)
    {
        GoBoardPosition diagPos = (GoBoardPosition)board_.getPosition( r + rowOffset, c + colOffset );
        if (diagPos == null || diagPos.isUnoccupied() || diagPos.getPiece().isOwnedByPlayer1() == groupP1 )
            return false;

        BoardPosition pos1 = board_.getPosition( r + rowOffset, c );
        BoardPosition pos2 = board_.getPosition( r, c + colOffset );

View Full Code Here

        float territoryEstimate = 0;

        // we should be able to just sum all the position scores now.
        for ( int i = 1; i <= board_.getNumRows(); i++ )  {
           for ( int j = 1; j <= board_.getNumCols(); j++ ) {
               GoBoardPosition pos = (GoBoardPosition) board_.getPosition(i, j);
               territoryEstimate += getTerritoryEstimateForPosition(pos, forPlayer1, isEndOfGame);
           }
        }
        return (int)territoryEstimate;
    }
View Full Code Here

        GoBoardPositionLists emptyLists = new GoBoardPositionLists();

        for ( int i = min; i <= rMax; i++ )  {
           for ( int j = min; j <= cMax; j++ ) {
               GoBoardPosition pos = (GoBoardPosition)board_.getPosition(i, j);
               diffScore += updateEmptyRegionFromSeed(box, emptyLists, pos);
           }
        }

        emptyLists.unvisitPositionsInLists();
View Full Code Here

        // perform a breadth first search  until all found.
        // use the visited flag to indicate that a stone has been added to the group
        GoBoardPositionList stack = new GoBoardPositionList();
        stack.add( 0, stone );
        while ( !stack.isEmpty() ) {
            GoBoardPosition s = stack.remove(stack.size()-1);
            if ( !s.isVisited()) {
                s.setVisited( true );
                assert (s.getPiece().isOwnedByPlayer1() == stone.getPiece().isOwnedByPlayer1()):
                       s + " does not have same ownership as " + stone;
                stones.add( s );
                pushGroupNeighbors(s, s.getPiece().isOwnedByPlayer1(), stack );
            }
        }
        if (returnToUnvisitedState) {
            stones.unvisitPositions();
        }
View Full Code Here

    GoGroupSet findAllGroups()  {
        GoGroupSet groups = new GoGroupSet();

        for ( int i = 1; i <= board_.getNumRows(); i++ )  {
            for ( int j = 1; j <= board_.getNumCols(); j++ ) {
                GoBoardPosition pos = (GoBoardPosition)board_.getPosition(i, j);
                if (pos.isOccupied() && !groups.containsPosition(pos)) {
                    // would this run faster if  second param was false?
                    groups.add(new GoGroup(findGroupFromInitialPosition(pos, true)));
                }
            }
        }
View Full Code Here

     * @return o or 1 depending on if diagonal neighbor
     */
    private int checkDiagonalNeighbor( int r, int c, int rowOffset, int colOffset,
                                       boolean friendPlayer1, boolean sameSideOnly,
                                       GoBoardPositionList stack ) {
        GoBoardPosition nbr = (GoBoardPosition) board_.getPosition(r + rowOffset, c + colOffset);
        if (nbr.isUnoccupied()) {
            return 0;
        }
        // determine the side we are checking for (one or the other)
        boolean sideTest = sameSideOnly ? friendPlayer1 : !friendPlayer1;
        if ( (nbr.getPiece().isOwnedByPlayer1() == sideTest) && !nbr.isVisited()) {
            BoardPosition diag1 = board_.getPosition(r + rowOffset, c);
            BoardPosition diag2 = board_.getPosition(r, c + colOffset);
            if (!isDiagonalCut(diag1, diag2, sideTest) )  {
                stack.add( 0, nbr );
                return 1;
View Full Code Here

     * @return return 1 or 0 depending on if there si a onespace neighbor
     */
    private int checkOneSpaceNeighbor( int r, int c, int rowOffset, int colOffset,
                                       boolean friendPlayer1, boolean samePlayerOnly,
                                       GoBoardPositionList stack ) {
        GoBoardPosition nbr = (GoBoardPosition)board_.getPosition(r + rowOffset, c + colOffset);
        // don't add it if it is in atari
        //if (nbr.isInAtari(board_))
        //    return 0;
        if ( nbr.isOccupied() &&
            (!samePlayerOnly || nbr.getPiece().isOwnedByPlayer1() == friendPlayer1) && !nbr.isVisited() ) {
            BoardPosition oneSpacePt;
            if ( rowOffset == 0 ) {
                int col = c + (colOffset >> 1);
                oneSpacePt = board_.getPosition(r, col);
            }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.go.board.elements.position.GoBoardPosition

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.