Package eas.simulation.spatial.sim2D.gridSimulation.standardGridObjects

Examples of eas.simulation.spatial.sim2D.gridSimulation.standardGridObjects.GridDoubleValue


        super.step(simTime);
       
        for (int i = 0; i < this.getWidth(); i++) {
            for (int j = 0; j < this.getHeight(); j++) {
                if (rand.nextDouble() < regrowRate) {
                    GridDoubleValue gdv = (GridDoubleValue) this.getFieldPosition(i, j).get(0);
                    double value = rand.nextDouble() * regrowRate;
                    value = gdv.getMaxValue() * value;
                   
                    if (value > gdv.getValue()) {
                        gdv.setValue(value);
                    }
                }
            }
        }
    }
View Full Code Here


            @Override
            public void actuate(StupidEnvironment env, StupidBug agent) {
                Vector2D pos = env.getAgentPosition(agent.id());
               
                GridDoubleValue gridDoubleValue = (GridDoubleValue) env.getFieldPosition(pos.x, pos.y).get(0);
                double fac = gridDoubleValue.getValue() / 200;
                myScale = myScale + fac;
                env.setAgentScale(agent.id(), new Vector2D((int) myScale, (int) myScale));
                gridDoubleValue.setValue(0);
            }

            @Override
            public String id() {
                return "Eat'n'grow";
View Full Code Here

            @Override
      public void actuate(StupidEnvironment env, StupidAgent agent) {

        Vector2D pos = new Vector2D(env.getAgentPosition(agent.id()));

        GridDoubleValue food = (GridDoubleValue) env.getFieldPosition(
            pos).get(0);
        agent.grow(food.getValue() / 255);
        ((GridDoubleValue) env.getFieldPosition(pos).get(0))
            .setValue(0);
      }

      @Override
View Full Code Here

    Random rnd = new Random(params.getSeed());

    for (int i = 0; i < env.getWidth(); i++) {
      for (int j = 0; j < env.getHeight(); j++) {
        GridDoubleValue food = new GridDoubleValue(
            rnd.nextDouble() * 250);
        env.addGridObject(food, i, j);
      }
    }

View Full Code Here

    }

    public GridDoubleValue getGridDoubleValue(double x, double y) {
        List<GridObject> liste = this.getFieldPosition(x, y);
        for (GridObject go : liste) {
            if (go.getClass().isInstance(new GridDoubleValue(0))) {
                return (GridDoubleValue) go;
            }
        }
        return null;
    }
View Full Code Here

        super.runBeforeSimulation(umg, params);
        Random rand = new Random(params.getSeed());
        CleaningEnvironment env = umg;
        for (int i = 0; i < env.getWidth(); i++) {
            for (int j = 0; j < env.getHeight(); j++) {
                GridDoubleValue gridDoubleValue = new GridDoubleValue(rand.nextDouble() * 250);
                env.addGridObject(gridDoubleValue, i, j);
            }
        }
    }
View Full Code Here

    @Override
    public void actuate(CleaningEnvironment env, AbstractAgent2D<?> agent) {
       
        // CLEAN
        Vector2D pos = env.getAgentPosition(agent.id());
        GridDoubleValue gridDoubleValue = env.getGridDoubleValue(pos.x, pos.y);
        if (gridDoubleValue.getValue() > 10) {
            double toClean = gridDoubleValue.getValue() / 1.2;
            gridDoubleValue.setValue(toClean);
        }

        // MOVE
        Vector2D position = env.getAgentPosition(agent.id());
        @SuppressWarnings("unchecked")
View Full Code Here

        StupidEnvironment env = new StupidEnvironment(0, params, size, size, true);
        Random rand = new Random();
       
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                GridDoubleValue gridDoubleValue = new GridDoubleValue(rand.nextDouble() * 10);
                gridDoubleValue.setMaxValColor(Color.green);
                env.addGridObject(gridDoubleValue, i, j);
            }
        }
       
        for (int i = 0; i < 2; i++) {
View Full Code Here

TOP

Related Classes of eas.simulation.spatial.sim2D.gridSimulation.standardGridObjects.GridDoubleValue

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.