src/model/agent/AgentFactory.java
public static Agent createAgent(PathFinder pathFinder, WorldWrapper worldWrapper, Parameters parameters) {
        DecisionContext context = new DecisionContext(worldWrapper, pathFinder, parameters);
        Agent agent = new Agent(context, Model.rand.nextDouble(), Model.rand.nextDouble(), Model.rand.nextDouble(),
                Model.rand.nextDouble(), (Model.rand.nextDouble() * 4) + 4);
        context.setAgent(agent);

        // find an available cell
        Cell cell = worldWrapper.getRandomCell(c -> worldWrapper.isFree(c.x, c.y));

        // put the agent in it
        agent.x = cell.x;
        agent.y = cell.y;
        cell.occupant = agent;

        log.finest("Created new agent at [" + agent.x + "," + agent.y + "]");
        return agent;
    }
/**
     * Creates a single agent, adds it to the world and returns it.
     */
Creates a single agent, adds it to the world and returns it.
Creates a single agent adds it to the world and returns it .
public static Agent createAgent(PathFinder pathFinder, WorldWrapper worldWrapper, Parameters parameters) {
        DecisionContext context = new DecisionContext(worldWrapper, pathFinder, parameters);
        Agent agent = new Agent(context, Model.rand.nextDouble(), Model.rand.nextDouble(), Model.rand.nextDouble(),
                Model.rand.nextDouble(), (Model.rand.nextDouble() * 4) + 4);
        context.setAgent(agent);
        Cell cell = worldWrapper.getRandomCell(c -> worldWrapper.isFree(c.x, c.y));
        agent.x = cell.x;
        agent.y = cell.y;
        cell.occupant = agent;
        log.finest("Created new agent at [" + agent.x + "," + agent.y + "]");
        return agent;
    }
public static Agent createAgent ( PathFinder pathFinder , WorldWrapper worldWrapper , Parameters parameters ) { DecisionContext context = new DecisionContext ( worldWrapper , pathFinder , parameters ) ; Agent agent = new Agent ( context , Model . rand . nextDouble ( ) , Model . rand . nextDouble ( ) , Model . rand . nextDouble ( ) , Model . rand . nextDouble ( ) , ( Model . rand . nextDouble ( ) * 4 ) + 4 ) ; context . setAgent ( agent ) ; Cell cell = worldWrapper . getRandomCell ( c -> worldWrapper . isFree ( c . x , c . y ) ) ; agent . x = cell . x ; agent . y = cell . y ; cell . occupant = agent ; log . finest ( "Created new agent at [" + agent . x + "," + agent . y + "]" ) ; return agent ; }
Creates a single agent, adds it to the world and returns it.
Creates a single agent adds it to the world and returns it .
// find an available cell // put the agent in it