Package com.barrybecker4.game.twoplayer.go

Examples of com.barrybecker4.game.twoplayer.go.GoController


     * @return   the message to display at the completion of the game.
     */
    @Override
    public String getText() {

        GoController gc = (GoController) controller_;

        String message = "\n";

        GoSearchable searchable = (GoSearchable) controller_.getSearchable();
        int blackCaptures = searchable.getNumCaptures(true) + searchable.getNumDeadStonesOnBoard(true);
        int whiteCaptures = searchable.getNumCaptures(false) + searchable.getNumDeadStonesOnBoard(false);


        String p1Name = gc.getPlayers().getPlayer1().getName();
        String p2Name = gc.getPlayers().getPlayer2().getName();

        message += p1Name +' '+ STONES_CAPTURED + blackCaptures +'\n';
        message += p2Name +' '+ STONES_CAPTURED + whiteCaptures +"\n\n";

        int blackTerritory = gc.getFinalTerritory(true);
        int whiteTerritory = gc.getFinalTerritory(false);
        message += p1Name +' '+ TERRITORY + blackTerritory +'\n';
        message += p2Name +' '+ TERRITORY + whiteTerritory +"\n\n";

        message += p1Name +' '+ SCORE + gc.getFinalScore(true) +'\n';
        message += p2Name +' '+ SCORE + gc.getFinalScore(false) +'\n';

        return super.getText() +'\n'+ message;
    }
View Full Code Here


        return new GoPlayerAssignmentPanel(get2PlayerController(), parent_);
    }

    @Override
    protected void ok() {
        GoController gcontroller = (GoController) controller_;

        assert ( handicapField_!=null );
        gcontroller.setHandicap( handicapField_.getIntValue() );

        GameContext.log( 2, "GoOptionsDlg: the handicap is:" + handicapField_.getIntValue());
        super.ok();
    }
View Full Code Here

     */
    @Override
    public void gameChanged( GameChangedEvent gce ) {

        super.gameChanged( gce );
        GoController goController = (GoController) controller_;

        if ( p1CapturesLabel_ == null )
            return;

        GoSearchable searchable = (GoSearchable) goController.getSearchable().copy();
        p1CapturesLabel_.setText( searchable.getNumCaptures( false ) + " " );
        p2CapturesLabel_.setText( searchable.getNumCaptures( true ) + " " );

        new BoardValidator(searchable.getBoard()).confirmStonesInValidGroups();
        p1TerritoryLabel_.setText( searchable.getTerritoryEstimate( true ) + " " );
View Full Code Here

        ParameterArray initialGuess = new TantrixPath(board);
        assert(initialGuess.size() > 0) : "The random path should have some tiles!";
        long startTime = System.currentTimeMillis();

        Optimizer optimizer = new Optimizer(this);
        optimizer.setListener(this);

        ParameterArray solution =
            optimizer.doOptimization(strategy, initialGuess, SOLVED_THRESH);

        solution_ =
            new TantrixBoard(((TantrixPath)solution).getTilePlacements(), board.getPrimaryColor());

        TilePlacementList moves;
View Full Code Here

     * @return list of moves to a solution.
     */
    @Override
    public TilePlacementList solve()  {

        ParameterArray initialGuess = new TantrixPath(board);
        assert(initialGuess.size() > 0) : "The random path should have some tiles!";
        long startTime = System.currentTimeMillis();

        Optimizer optimizer = new Optimizer(this);
        optimizer.setListener(this);

        ParameterArray solution =
            optimizer.doOptimization(strategy, initialGuess, SOLVED_THRESH);

        solution_ =
            new TantrixBoard(((TantrixPath)solution).getTilePlacements(), board.getPrimaryColor());

View Full Code Here

     * Draw one of the tile paths which takes one of three forms.
     */
    public void drawPath(Graphics2D g2, int pathNumber, TilePlacement tilePlacement,
                         Point position, double size) {

        HexTile tile = tilePlacement.getTile();
        int pathStartIndex = getPathStartIndex(tile, pathNumber);

        int i = pathStartIndex + 1;

        PathColor pathColor = tile.getEdgeColor(pathStartIndex);
        while (pathColor != tile.getEdgeColor(i++)) {
            assert(i<6): "Should never exceed 6";
        }

        int pathEndIndex = i-1;
        int diff = pathEndIndex - pathStartIndex;
View Full Code Here

        this.numTiles = numTiles;
    }

    public TantrixBoard initialPosition() {
        //MathUtil.RANDOM.setSeed(1);
        return new TantrixBoard(new HexTiles().createRandomList(numTiles));
    }
View Full Code Here

    public boolean isGoal(TantrixBoard position) {
        return position.isSolved();
    }

    public TilePlacementList legalMoves(TantrixBoard position) {
        return new MoveGenerator(position).generateMoves();
    }
View Full Code Here

        HexTile tile = tilePlacement.getTile();
        int pathStartIndex = getPathStartIndex(tile, pathNumber);

        int i = pathStartIndex + 1;

        PathColor pathColor = tile.getEdgeColor(pathStartIndex);
        while (pathColor != tile.getEdgeColor(i++)) {
            assert(i<6): "Should never exceed 6";
        }

        int pathEndIndex = i-1;
View Full Code Here

     */
    private int getPathStartIndex(HexTile tile, int pathNumber) {
        Set<PathColor> set = new HashSet<PathColor>();
        int i = 0;
        do {
            PathColor c = tile.getEdgeColor(i++);
            set.add(c);
        } while (set.size() <= pathNumber);
        return i-1;
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.go.GoController

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.