Package com.barrybecker4.simulation.liquid.model

Examples of com.barrybecker4.simulation.liquid.model.Grid


        boolean perfectLoop = false;
        double compactness = determineCompactness(path);

        if (consistentLoop) {
            Tantrix tantrix = new Tantrix(path.getTilePlacements());
            InnerSpaceDetector innerDetector = new InnerSpaceDetector(tantrix);
            perfectLoop = !innerDetector.hasInnerSpaces();
            //System.out.println("perfect loop");
        }

        double fitness =
                LOOP_PROXIMITY_WEIGHT * (numTiles - distance) / (0.1 + numTiles)
View Full Code Here


                               boolean useConcurrency) {
        super(board);
        puzzlePanel_ = puzzlePanel;
        strategy = useConcurrency ? OptimizationStrategyType.CONCURRENT_GENETIC_SEARCH :
                                    OptimizationStrategyType.GENETIC_SEARCH;
        evaluator = new PathEvaluator();
    }
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);

View Full Code Here

     * We show the current status.
     * @param params
     */
    public void optimizerChanged(ParameterArray params) {
        // update our current best guess at the solution.
        TantrixPath path = (TantrixPath)params;
        solution_ = new TantrixBoard(path.getTilePlacements(), path.getPrimaryPathColor());
        puzzlePanel_.refresh(solution_, numTries_++);
    }
View Full Code Here

    /**
     * Constructor.
     */
    public TantrixViewer() {
        renderer_ = new TantrixBoardRenderer();
    }
View Full Code Here

    /**
     * figure out the biggest scale based in on which dimension is bumped up to first
     */
    private void determinScaling(int width, int height) {

        Grid grid = env_.getGrid();
        double proposedXScale = width / grid.getXDimension();
        double proposedYScale = height / grid.getYDimension();
        setScale(Math.min(proposedXScale, proposedYScale));
    }
View Full Code Here

     * draw the cells/grid_
     */
    private void drawGrid(Graphics2D g) {

        g.setColor( GRID_COLOR );
        Grid grid = env_.getGrid();
        int xDim = grid.getXDimension();
        int yDim = grid.getYDimension();
        int rightEdgePos = (int) (scale_ * xDim);
        int bottomEdgePos = (int) (scale_ * yDim);
        int maxY = (int)getMaxY();

        for (int  j = 0; j < yDim; j++ )   //  -----
View Full Code Here

    private void drawParticleVelocities(Graphics2D g) {

        g.setStroke( PARTICLE_VELOCITY_STROKE);
        g.setColor( PARTICLE_VELOCITY_COLOR );
        double[] a_ = new double[2];
        Grid grid = env_.getGrid();
        VelocityInterpolator interpolator = new VelocityInterpolator(grid);
        double maxY = getMaxY();

        for (Particle p : env_.getParticles()) {
            if (options.getShowVelocities()) {
View Full Code Here

    /**
     * PathColor the squares according to the pressure in that discrete region.
     */
    private void renderPressure(Graphics2D g) {
        Grid grid = env_.getGrid();
        double maxY = getMaxY();

        for (int j = 0; j < grid.getYDimension(); j++ ) {
            for (int i = 0; i < grid.getXDimension(); i++ ) {
                g.setColor( pressureColorMap_.getColorForValue( grid.getCell(i, j).getPressure() ) );
                g.fillRect( (int) (scale_ * (i)) + OFFSET, (int) (maxY - scale_ * (j)),
                            (int) scale_, (int) scale_ );
            }
        }
    }
View Full Code Here

    /**
     * draw text representing internal state for debug purposes.
     */
    private void drawCellSymbols(Graphics2D g) {

        Grid grid = env_.getGrid();
        g.setColor( TEXT_COLOR );
        g.setFont( BASE_FONT );
        StringBuilder strBuf = new StringBuilder( "12" );
        double maxY = getMaxY();

        for ( int j = 0; j < grid.getYDimension(); j++ ) {
            for (int  i = 0; i < grid.getXDimension(); i++ ) {
                int x = (int) (scale_ * i) + OFFSET;
                int y = (int) (maxY - scale_ * (j + 1));
                strBuf.setCharAt( 0, grid.getCell(i, j).getStatus().getSymbol() );
                strBuf.setLength( 1 );
                //int nump = grid.getCell(i, j).getNumParticles();
                //if ( nump > 0 )
                //    strBuf.append( String.valueOf( nump ) );
                g.drawString( strBuf.toString(), x + 6, y + 18 );
View Full Code Here

TOP

Related Classes of com.barrybecker4.simulation.liquid.model.Grid

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.