Examples of GoController


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

        }
        return status;
    }

    private void initSize(int size) {
        controller_ = new GoController(size, 0);
        SearchOptions options =
            ( (TwoPlayerPlayerOptions)controller_.getCurrentPlayer().getOptions() ).getSearchOptions();

        options.getBruteSearchOptions().setAlphaBeta(true);
        options.getBruteSearchOptions().setLookAhead(2);
View Full Code Here

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

        getBoardRenderer().setDraggedShowPiece(null);
    }

    @Override
    protected GameController createController()  {
        return new GoController();
    }
View Full Code Here

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

     * Constructor.
     */
    public GoViewerMouseListener(GameBoardViewer viewer) {
        super(viewer);

        GoController controller = (GoController) viewer.getController();
        if (!controller.getPlayers().allPlayersComputer()) {
            getRenderer().setDraggedShowPiece(
                    new GoBoardPosition(0, 0, null, new GoStone(controller.isPlayer1sTurn())));
            savedShowPiece_ = getRenderer().getDraggedShowPiece();
        }
    }
View Full Code Here

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

     *  mouseClicked requires both the mouse down and mouse up event to occur at the same location.
     */
    @Override
    public void mousePressed( MouseEvent e ) {

        GoController controller = (GoController) viewer_.getController();
        // all derived classes must check this to disable user clicks while the computer is thinking
        if (controller.isProcessing()) {
            return;
        }
        Location loc = getRenderer().createLocation(e);
        GoBoard board = (GoBoard) controller.getBoard();
        boolean player1sTurn = controller.isPlayer1sTurn();

        GameContext.log( 3, "BoardViewer: mousePressed: player1sTurn()=" + player1sTurn);

        GoMove m = new GoMove( loc, 0, new GoStone(player1sTurn));

View Full Code Here

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

    /**
     * Place the stone on the board.
     */
    private void processStonePlacement(Location loc, GoMove m, GoBoardPosition stone) {

        GoController controller = (GoController) viewer_.getController();
        GoBoard board = (GoBoard) controller.getBoard();
        boolean player1sTurn = controller.isPlayer1sTurn();

        if ( stone.isOccupied() ) {
            JOptionPane.showMessageDialog( null, GameContext.getLabel("CANT_PLAY_ON_STONE") );
            GameContext.log( 0, "BoardViewer: There is already a stone there: " + stone );
            return;
        }
        if ( GoMoveGenerator.isTakeBack(m.getToRow(), m.getToCol(), (GoMove) controller.getLastMove(), board) ) {
            JOptionPane.showMessageDialog( null, GameContext.getLabel("NO_TAKEBACKS"));
            return;
        }
        assert(!stone.isVisited());

        if (m.isSuicidal(board)) {
            JOptionPane.showMessageDialog( null, GameContext.getLabel("SUICIDAL") );
            GameContext.log( 1, "BoardViewer: That move is suicidal (and hence illegal): " + stone );
            return;
        }

        if ( !((AbstractTwoPlayerBoardViewer)viewer_).continuePlay( m ) ) {   // then game over
            getRenderer().setDraggedShowPiece(null);
        }
        else if (controller.getPlayers().allPlayersHuman()) {
            // create a stone to show for the next players move
            getRenderer().setDraggedShowPiece(
                    new GoBoardPosition(loc.getRow(), loc.getCol(), null, new GoStone(!player1sTurn)));
        }
    }
View Full Code Here

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

     * When the player clicks the wall is irrevocably placed.
     */
    @Override
    public void mouseMoved( MouseEvent e )
    {
        GoController controller = (GoController) viewer_.getController();
        if (controller.isProcessing()) {
            return;
        }
        Location loc = getRenderer().createLocation(e);

        if ( getRenderer().getDraggedShowPiece() != null ) {
View Full Code Here

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

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

        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

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

     */
    @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
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.