Package com.barrybecker4.game.common

Examples of com.barrybecker4.game.common.Move


    public void makeMoveSequence( List moveSequence,
                                        int numMovesToBackup ) {
        if ( moveSequence == null || moveSequence.size() == 0 ){
            return;
        }
        Move firstMove = (Move) moveSequence.get( 0 );
        // the first time we click on a row in the tree, the controller has no moves.
        Move lastMove = controller_.getLastMove();

        if ( lastMove == null ) {
            controller_.reset(); // was AbsTwoPlayerBoardViewer.reset()
        }
        else {
View Full Code Here


    public void undoLastManMove()  {
        TwoPlayerController c = get2PlayerController();
        PlayerList players = c.getPlayers();
        if ( players.allPlayersComputer() )
            return;
        Move move = c.undoLastMove();
        if ( move != null ) {
            undoneMoves_.add( move );
            if ( !players.allPlayersHuman() ) {
                undoneMoves_.add( c.undoLastMove() );
            }
View Full Code Here

    protected void writeMoves(MoveList moves, Writer out) throws IOException {
        Iterator<Move> it = moves.iterator();
        GameContext.log( 0, "movelist size= " + moves.size() );
        while ( it.hasNext() ) {
            Move move = it.next();
            out.write( getSgfForMove(move) );
        }
    }
View Full Code Here

    private MoveList determineMovesExceedingValueThresh(MoveList moveList, int minBest, int percentLessThanBestThresh) {

        int numMoves = moveList.size();
        MoveList bestMoveList = new MoveList();
        if (numMoves > 0) {
            Move currentMove = moveList.getFirstMove();
            double thresholdValue = currentMove.getValue() * (1.0  - (float)percentLessThanBestThresh/100.0);
            double sign = thresholdValue < 0 ? -1 :1;

            bestMoveList.add(currentMove);
            int ct = 1;

            while ((sign * currentMove.getValue() >= sign * thresholdValue || ct < minBest) && ct < numMoves) {
                currentMove = moveList.get(ct++);
                bestMoveList.add(currentMove);
            }
        }
        return bestMoveList;
View Full Code Here

        //System.err.println("time_left = main="+ cmdArray[1] ); //+"  byo_yomi=" + byo_yomi_time +" stones=" + byo_yomi_stones);
        return true;
    }

    private boolean cmdUndo(StringBuffer response) {
        Move m = controller_.undoLastMove();
        if (m == null) {
            response.append("cannot undo");
            return false;
        }
        return true;
View Full Code Here

     *
     * @param forPlayer1 if true, get the captures for player1, else for player2
     * @return estimate of the amount of territory the player has
     */
    public int getTerritoryEstimate( boolean forPlayer1 ) {
        Move m = moveList_.getLastMove();
        if ( m == null )
            return 0;

        return boardEvaluator_.getTerritoryEstimate(forPlayer1, false);
    }
View Full Code Here

     */
    @Override
    public void update(GameController controller) {

        setPlayerLabel(controller.getCurrentPlayer());
        Move lastMove =  controller.getLastMove();
        if (lastMove != null)  {
            moveNumLabel_.setText( (controller.getNumMoves() + 2) + " " );
        }
        else {
            moveNumLabel_.setText( 1 + " " );
View Full Code Here

     */
    protected void restoreGame( SGFGame game )
    {
        parseSGFGameInfo(game);

        MoveList moveSequence = new MoveList();
        extractMoveList( game.getTree(), moveSequence );
        GameContext.log( 1, "move sequence= " + moveSequence );
        controller_.reset();

        for (Move m : moveSequence) {
View Full Code Here

     * This renders the current state of the Board to the screen.
     */
    public void render(Graphics g, Player currentPlayer, PlayerList players,
                       IBoard board, int panelWidth, int panelHeight ) {

        Board b = (Board)board;
        cellSize = calcCellSize( b, panelWidth, panelHeight );

        if ( draggedShowPiece_!=null) {
            draggedShowPiece_.getPiece().setTransparency( DRAG_TRANSPARENCY );
        }

        Graphics2D g2 = (Graphics2D)g;

        int gridOffset = 0;
        int start = 0;
        int nrows = b.getNumRows();
        int ncols = b.getNumCols();
        int nrows1 = nrows;
        int ncols1 = ncols;
        // if the grid is offset, it means the pieces will be shown at the vertices.
        if ( offsetGrid() ) {
            gridOffset = cellSize >> 1;
View Full Code Here

            throw new RuntimeException(e);
        }

        try {
            // initial update to the game tables for someone entering the room.
            GameCommand cmd = new GameCommand(GameCommand.Name.UPDATE_TABLES, cmdProcessor.getTables());
            update(cmd);

            while (!stopped) {
                // receive the serialized commands that are sent and process them.
                cmd = (GameCommand) iStream.readObject();
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.common.Move

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.