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

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


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


     *  because one of them is dead.
     */
    @Override
    public boolean isEnemy( GoBoardPosition pos) {
        assert (pos.isOccupied());
        GoStone stone = (GoStone)pos.getPiece();
        return stone.isOwnedByPlayer1() != isOwnedByPlayer1(); // && !muchWeaker);
    }
View Full Code Here

        IGoGroup g = getGroup();
        assert (g != null): "group for "+ this +" is null";
        if (pos.isUnoccupied()) {
            return false;
        }
        GoStone stone = (GoStone)pos.getPiece();

        assert (g.isOwnedByPlayer1() == isOwnedByPlayer1()):
                 "Bad group ownership for eye="+ this +". Owning Group="+g;
        return (stone.isOwnedByPlayer1() != isOwnedByPlayer1()); // && !weaker);
    }
View Full Code Here

        boolean player1 = token instanceof AddBlackToken;

        while (points.hasNext()) {
            Point point = points.next();
            //System.out.println("adding move at row=" + point.y+" col="+ point.x);
            moveList.add( new GoMove( new ByteLocation(point.y, point.x), 0, new GoStone(player1)));
        }
    }
View Full Code Here

          if (mvToken.isPass()) {
              return GoMove.createPassMove(0, !mvToken.isWhite());
          }
          return new GoMove(
                  new ByteLocation(mvToken.getY(), mvToken.getX()),
                  0, new GoStone(!mvToken.isWhite()));
    }
View Full Code Here

            min = 3;
        int max = boardSize - (min-1);
        int mid = (boardSize >> 1) + 1;

        // add the star points
        GoStone handicapStone = new GoStone(true, HANDICAP_STONE_HEALTH);
        starPoints_.add( new GoBoardPosition( min, min, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( max, max, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( min, max, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( max, min, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( min, mid, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( max, mid, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( mid, min, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( mid, max, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( mid, mid, null, handicapStone) );
    }
View Full Code Here

     *   X X
     *   X X
     */
    public int formsBadShape(GoBoardPosition position)
    {
        GoStone stone = (GoStone)position.getPiece();
        int r = position.getRow();
        int c = position.getCol();

        return checkBadShape(stone, r, c,  1,-1)
             + checkBadShape(stone, r, c, -1,-1)
View Full Code Here

                correctNeighborType = nbrStone.isUnoccupied();
                break;
            case ENEMY: // the opposite color
                if (nbrStone.isUnoccupied())
                    return;
                GoStone st = (GoStone)nbrStone.getPiece();
                correctNeighborType =  st.isOwnedByPlayer1() != friendOwnedByP1;
                break;
            case FRIEND: // the same color
                if (nbrStone.isUnoccupied())
                    return;
                correctNeighborType = (nbrStone.getPiece().isOwnedByPlayer1() == friendOwnedByP1);
                break;
            case NOT_FRIEND: // the opposite color or empty
                GoStone stone = (GoStone)nbrStone.getPiece();
                correctNeighborType = (nbrStone.isUnoccupied() || stone.isOwnedByPlayer1() != friendOwnedByP1);
                break;
        }
        if (correctNeighborType ) {
            nbrs.add( nbrStone );
        }
View Full Code Here

     *  If the difference in health between the stones is great, then they are not really enemies
     *  because one of them is dead.
     */
    public boolean isTrueEnemy(GoBoardPosition pos) {
        assert (pos.isOccupied());
        GoStone stone = (GoStone)pos.getPiece();
        boolean muchWeaker = isStoneMuchWeakerThanGroup(stone);

        return ( stone.isOwnedByPlayer1() != group_.isOwnedByPlayer1() && !muchWeaker);
    }
View Full Code Here

           for ( int j = 1; j <= board_.getNumCols(); j++ ) {
               GoBoardPosition pos = (GoBoardPosition)board_.getPosition(i, j);
               pos.setScoreContribution(0);

               if (pos.isOccupied()) {
                   GoStone stone = ((GoStone)pos.getPiece());
                   stone.setHealth(0);
               }
           }
        }
    }
View Full Code Here

TOP

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

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.