Package com.barrybecker4.game.common.board

Examples of com.barrybecker4.game.common.board.GamePiece


    public void computerMovesFirst() {
        int delta = getWinRunLength() - 1;
        Board b = (Board) getBoard();
        int c = (int) (GameContext.random().nextFloat() * (b.getNumCols() - 2 * delta) + delta + 1);
        int r = (int) (GameContext.random().nextFloat() * (b.getNumRows() - 2 * delta) + delta + 1);
        TwoPlayerMove m = TwoPlayerMove.createMove( r, c, 0, new GamePiece(true) );
        makeMove( m );
    }
View Full Code Here


        if ( (p == null) || !p.isUnoccupied() )
            return;

        TwoPlayerMove m =
            TwoPlayerMove.createMove( loc.getRow(), loc.getCol(), 0,
                                      new GamePiece(controller.isPlayer1sTurn()));

        viewer.continuePlay( m );
    }
View Full Code Here

     */
    public int worth( TwoPlayerMove lastMove, ParameterArray weights ) {

        int row = lastMove.getToRow();
        int col = lastMove.getToCol();
        GamePiece piece = board_.getPosition(row, col).getPiece();
        assert piece != null :
                "There must be a piece where the last move was played (" + row+", " + col + ")";
        assert (lastMove.isPlayer1() == piece.isOwnedByPlayer1()) :
                "The last move played must be for the same player found on the board.";

        // look at every string that passes through this new move to see how the value is effected.
        int diff;
        diff = horzDifferencer.findValueDifference(row, col, weights);
View Full Code Here

        for (int i = 1; i <= ncols; i++ ) {
            for (int j = 1; j <= nrows; j++ ) {
                if ( pb.isCandidateMove( j, i )) {
                    TwoPlayerMove m;
                    if (lastMove == null)
                       m = TwoPlayerMove.createMove( j, i, 0, new GamePiece(player1));
                    else
                       m = TwoPlayerMove.createMove( j, i, lastMove.getValue(), new GamePiece(player1));
                    searchable_.makeInternalMove( m );
                    m.setValue(searchable_.worth( m, weights));
                    // now revert the board
                    searchable_.undoInternalMove( m );
                    moveList.add( m );
View Full Code Here

            TwoPlayerMove move = (TwoPlayerMove) m;
            // if its not a winning move or we already have it, then skip
            if ( Math.abs(move.getValue()) >= WINNING_VALUE  && !contains(move, urgentMoves) ) {
                move.setUrgent(true);
                move.setPlayer1(currentPlayer);
                move.setPiece(new GamePiece(currentPlayer));
                urgentMoves.add(move);
            }
        }
        return urgentMoves;
    }
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

            default:
                assert false : "Unhandled command: "+ cmd;
        }

        if (useUpdateTable) {
            GameCommand response = new GameCommand(GameCommand.Name.UPDATE_TABLES, getTables());
            responses.add(0, response)// add as first command in response.
        }

        return responses;
    }
View Full Code Here

        // get all robot player actions until the next human player
        List<PlayerAction> robotActions = ((MultiGameController)controller_).getRecentRobotActions();

        for (PlayerAction act : robotActions) {
            GameCommand robotCmd = new GameCommand(GameCommand.Name.DO_ACTION, act);
            GameContext.log(0, "adding response command for robot action on server :" + robotCmd);
            responses.add(robotCmd);
        }
    }
View Full Code Here

        GameContext.log(0, "UpdateWorker terminated.");
    }

    private void processNextCommand() throws IOException, ClassNotFoundException {

        GameCommand cmd = (GameCommand) inputStream.readObject();
        GameContext.log(0, "Client Connection: got an update from the server:" + cmd);

        boolean processed = false;
        int count = 0;
View Full Code Here

                GameContext.log(2, "chat message=" + cmd.getArgument());
                useUpdateTable = false;
                responses.add(cmd);
                break;
            case START_GAME:
                OnlineGameTable tableToStart = (OnlineGameTable) cmd.getArgument();
                startGame(tableToStart);
                useUpdateTable = false;
                tableManager.removeTable(tableToStart);
                break;
            case DO_ACTION :
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.common.board.GamePiece

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.