Package com.barrybecker4.optimization

Examples of com.barrybecker4.optimization.Optimizer


     * @return done return true if the game is over after moving
     */
    @Override
    public boolean doComputerMove(Player player) {
        assert(!player.isHuman());
        GalacticRobotPlayer robot = (GalacticRobotPlayer)player;
        GalacticController gc = (GalacticController) controller_;
        GameContext.log(1, "now doing computer move. about to make orders");

        robot.makeOrders((Galaxy)getBoard(), gc.getNumberOfYearsRemaining());

        /* // records the result on the board.
        Move lastMove = getController().getLastMove();
        GalacticTurn gmove = GalacticTurn.createMove((lastMove==null)? 0 : lastMove.moveNumber + 1);
        gc.makeMove(gmove);
View Full Code Here


     * The dialog needs the user to dismiss it when done.
     * It is not shown if all computer players.
     * @param battle  the battle to show in a separate dialog
     */
    private void showBattle(BattleSimulation battle) {
        BattleDialog bDlg = new BattleDialog(parent_, battle, this);
        //bDlg.setLocationRelativeTo(this);

        Point p = this.getParent().getLocationOnScreen();
        // offset the dlg so the Galaxy grid is visible as a reference.
        bDlg.setLocation((int) (p.getX() + getParent().getWidth()),
                         (int) (p.getY() + 0.65 * getParent().getHeight()));
        bDlg.setModal(true);
        bDlg.setVisible(true);
    }
View Full Code Here

    }

    @Override
    protected NewGameDialog createNewGameDialog(Component parent, GameViewModel viewer )
    {
        return new GalacticNewGameDialog( parent, viewer );
    }
View Full Code Here

    }

    @Override
    protected GameOptionsDialog createOptionsDialog(Component parent, GameController controller )
    {
        return new GalacticOptionsDialog( parent, controller );
    }
View Full Code Here

     * display a dialog at the end of the game showing who won and other relevant
     * game specific information.
     */
    @Override
    public void showWinnerDialog() {
        GalacticTallyDialog tallyDialog = new GalacticTallyDialog(parent_, (GalacticController)controller_);
        tallyDialog.showDialog();
    }
View Full Code Here

     */
    private void showOrdersDialog(GalacticController gc) {

        GalacticPlayer currentPlayer = (GalacticPlayer)gc.getCurrentPlayer();

        OrdersDialog ordersDialog =
                new OrdersDialog(null, currentPlayer, gc.getNumberOfYearsRemaining());
        Point p = getParent().getLocationOnScreen();

        // offset the dlg so the Galaxy grid is visible as a reference
        ordersDialog.setLocation((int)(p.getX()+0.7*getParent().getWidth()), (int)(p.getY()+getParent().getHeight()/3.0));

        boolean canceled = ordersDialog.showDialog();
        if ( !canceled ) { // newGame a game with the newly defined options
            currentPlayer.setOrders( ordersDialog.getOrders() );
            gc.advanceToNextPlayer();
        }
    }
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

    /**
     * Let the computer play against itself for a long time as it optimizes its parameters.
     * @return the resulting optimized parameters.
     */
    public ParameterArray runOptimization() {
        Optimizer optimizer = new Optimizer( this.getOptimizee(), getTwoPlayerOptions().getAutoOptimizeFile() );

        ParameterArray optimizedParams;
        optimizedParams =
                optimizer.doOptimization(OptimizationStrategyType.HILL_CLIMBING,
                                         getComputerWeights().getDefaultWeights(),
                                         WINNING_VALUE);
        return optimizedParams;
    }
View Full Code Here

        ParameterArray initialGuess = new PieceParameterArray(pieces_);
        solution_ = pieces_;
        long startTime = System.currentTimeMillis();

        Optimizer optimizer = new Optimizer(this);

        optimizer.setListener(this);

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

        solution_ = ((PieceParameterArray)solution).getPieceList();
        List<Piece> moves;
        if (evaluateFitness(solution) >= MAX_FITS) {
            moves = solution_.getPieces();
View Full Code Here

     */
    public static void main(String[] args) {

        OptimizeeProblem testProblem = new TrivialProblem();

        Optimizer optimizer = new Optimizer(testProblem, "test/temp.txt");

        Point2d solutionPosition = new Point2d(TrivialProblem.SOLUTION_VALUE, TrivialProblem.SOLUTION_VALUE);
        OptimizationStrategyType strategy = OptimizationStrategyType.GLOBAL_SAMPLING;

        new OptimizerEvalFrame(optimizer, solutionPosition, strategy, testProblem);
View Full Code Here

TOP

Related Classes of com.barrybecker4.optimization.Optimizer

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.