Examples of GoBoardPositionList


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

     * @param returnToUnvisitedState if true, then mark everything unvisited when done.
     * @return the list of stones in the group that was found.
     */
    GoBoardPositionList findGroupFromInitialPosition( GoBoardPosition stone,
                                                      boolean returnToUnvisitedState ) {
        GoBoardPositionList stones = new GoBoardPositionList();
        // 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 );
View Full Code Here

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

     * @param samePlayerOnly if true then find group nbrs that are have same ownership as friendPlayer1
     * @return group neighbors for specified stone.
     */
    GoBoardPositionSet findGroupNeighbors(GoBoardPosition stone,
                                            boolean friendPlayer1, boolean samePlayerOnly) {
        GoBoardPositionList stack = new GoBoardPositionList();

        pushGroupNeighbors( stone, friendPlayer1, stack, samePlayerOnly );
        GoBoardPositionSet nbrStones = new GoBoardPositionSet();
        nbrStones.addAll( stack );

View Full Code Here

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

     * @return string from seed stone.
     */
    public GoBoardPositionList findStringFromInitialPosition( GoBoardPosition stone,  boolean friendOwnedByP1,
                                                     boolean returnToUnvisitedState, NeighborType type, Box box) {
        GoProfiler.getInstance().startFindStrings();
        GoBoardPositionList stones =
                stringNbrAnalyzer_.findStringFromInitialPosition(stone, friendOwnedByP1, returnToUnvisitedState,
                                                 type, box);
        GoProfiler.getInstance().stopFindStrings();

        return stones;
View Full Code Here

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

     * @return string from seed stone
     */
    GoBoardPositionList findStringFromInitialPosition(GoBoardPosition stone, boolean friendOwnedByP1,
                                                      boolean returnToUnvisitedState, NeighborType type,
                                                      Box box) {
        GoBoardPositionList stones = new GoBoardPositionList();

        GoBoardPositionList stack = new GoBoardPositionList();
        assert box.contains(stone.getLocation()) : "stone " +  stone + " not in " + box;

        assert ( !stone.isVisited() ): "stone="+stone;
        stack.add( 0, stone );
        while ( !stack.isEmpty() ) {
            GoBoardPosition s = stack.pop();
            if ( !s.isVisited() ) {
                s.setVisited( true );
                stones.add( s );
                pushStringNeighbors(s, friendOwnedByP1, stack, true, type,  box);
            }
View Full Code Here

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

    private Map<GoBoardPosition, GoBoardPositionList> createMap() {
        Map<GoBoardPosition, GoBoardPositionList> nbrMap = new HashMap<GoBoardPosition, GoBoardPositionList>();
        // we should probably be able to assume that the eye spaces_ are unvisited, but apparently not. assert instead?
        eye_.setVisited(false);

        GoBoardPositionList queue = new GoBoardPositionList();
        GoBoardPosition firstPos = eye_.getMembers().iterator().next();
        firstPos.setVisited(true);
        queue.add(firstPos);

        int count = processSearchQueue(queue, nbrMap);

        if (count != eye_.getMembers().size()) {
            throw new IllegalArgumentException("The eye string must not have been nobi connected because " +
View Full Code Here

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

     */
    private int processSearchQueue(GoBoardPositionList queue, Map<GoBoardPosition, GoBoardPositionList> nbrMap) {
        int count = 0;
        while (!queue.isEmpty()) {
            GoBoardPosition current = queue.remove(0);
            GoBoardPositionList nbrs = getEyeNobiNeighbors(current);
            nbrMap.put(current, nbrs);
            count++;
            for (GoBoardPosition space : nbrs)  {
                if (!space.isVisited()) {
                    space.setVisited(true);
View Full Code Here

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

     * @param space eye space to check
     * @return number of eye-space nobi neighbors.
     * these neighbors may either be blanks or dead stones of the opponent
     */
    private GoBoardPositionList getEyeNobiNeighbors(GoBoardPosition space) {
        GoBoardPositionList nbrs = new GoBoardPositionList();
        for (GoBoardPosition eyeSpace : eye_.getMembers()) {

            if ( space.isNeighbor( eyeSpace ))
                nbrs.add(eyeSpace);
        }
        return nbrs;
    }
View Full Code Here

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

                   return handleVitalPointCases(nbrMap, eye, 4);
                }
            case E122223 :
                return handleVitalPointCases(nbrMap, eye, 5);
            case E112224 :
                GoBoardPositionList endFilledSpaces = findSpecialFilledSpaces(nbrMap, getEndPoints(), eye);
                switch (endFilledSpaces.size()) {
                    case 0 return handleVitalPointCases(nbrMap, eye, 2);
                    case 1 return handleVitalPointCases(nbrMap, eye, 1); // replace with handleLifeProp? see page 122
                    default : assert false : "unexpected number of end spaces filled";
                }
                break;
View Full Code Here

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

     * if the box defined by those 2 positions contains the other 4 spaces, then case b, else a
     * @return the subtype E112233a or E112233b
     */
    private Eye6Type determineE112233Subtype(EyeNeighborMap nbrMap) {

        GoBoardPositionList oneNbrPoints = new GoBoardPositionList();
        GoBoardPositionList otherPoints = new GoBoardPositionList();

        for (GoBoardPosition pos : nbrMap.keySet()) {
            if (nbrMap.getNumEyeNeighbors(pos) == 1)  {
               oneNbrPoints.add(pos);
            }
            else {
               otherPoints.add(pos);
            }
        }
        assert oneNbrPoints.size() == 2 : "Did not get 2 one nbr points. Instead got "
                + oneNbrPoints.size()+ "\n nbrmap="+ nbrMap;
        Box bounds = new Box(oneNbrPoints.getFirst().getLocation(), oneNbrPoints.get(1).getLocation());
View Full Code Here

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

     * If all but one vital point has been filled, then we are unsettles - could be on eor two eyes.
     * If 2 or more vitals are still open, then we assume that this will become 2 eyes.
     * @return status of shape with numVitals vital points.
     */
    EyeStatus handleVitalPointCases(EyeNeighborMap nbrMap, IGoEye eye, final int numVitals)   {
        GoBoardPositionList vitalFilledSpaces = findSpecialFilledSpaces(nbrMap, getVitalPoints(), eye);
        int numFilledVitals = vitalFilledSpaces.size();
        assert numFilledVitals <= numVitals :
                "The number of filled vitals (" + numFilledVitals + ") " +
                "was greater than the total number of vitals ("+ numVitals + ") vitals="
                + Arrays.toString(getVitalPoints()) + " eye="+ eye;

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.