Package eas.users.ocScenarios.oclrss12.gruppe3

Source Code of eas.users.ocScenarios.oclrss12.gruppe3.SwarmScheduler

/*
* File name:        SwarmScheduler.java (package eas.users.students.viwawo.Aufgabe4)
* Author(s):        Christoph Vierheilig, Lars Wassermann, Philipp Wolfer
* Java version:     6.0
* Generation date:  23.06.2012 (10:43:15)
*
* (c) This file and the EAS (Easy Agent Simulation) framework containing it
* is protected by Creative Commons by-nc-sa license. Any altered or
* further developed versions of this file have to meet the agreements
* stated by the license conditions.
*
* In a nutshell
* -------------
* You are free:
* - to Share -- to copy, distribute and transmit the work
* - to Remix -- to adapt the work
*
* Under the following conditions:
* - Attribution -- You must attribute the work in the manner specified by the
*   author or licensor (but not in any way that suggests that they endorse
*   you or your use of the work).
* - Noncommercial -- You may not use this work for commercial purposes.
* - Share Alike -- If you alter, transform, or build upon this work, you may
*   distribute the resulting work only under the same or a similar license to
*   this one.
*
* + Detailed license conditions (Germany):
*   http://creativecommons.org/licenses/by-nc-sa/3.0/de/
* + Detailed license conditions (unported):
*   http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en
*
* This header must be placed in the beginning of any version of this file.
*/

package eas.users.ocScenarios.oclrss12.gruppe3;

import java.io.File;

import eas.math.geometry.Vector2D;
import eas.plugins.PluginProperties;
import eas.plugins.masterScheduler.AbstractDefaultMaster;
import eas.simulation.ConstantsSimulation;
import eas.simulation.spatial.sim2D.standardAgents.AbstractAgent2D;
import eas.simulation.spatial.sim2D.standardAgents.ObstacleAgent;
import eas.simulation.spatial.sim2D.standardAgents.wandaRobot.WandaAgent;
import eas.simulation.spatial.sim2D.standardEnvironments.WandaEnvironment;
import eas.simulation.spatial.standardBrains.mdle.MDL2eBrain;
import eas.startSetup.ParCollection;

/**
* Scheduler, der die Simulation anstoeßt
*
* @author Christoph Vierheilig, Lars Wassermann, Philipp Wolfer
*
*/
@PluginProperties(pluginIsHidden = false)
public class SwarmScheduler extends AbstractDefaultMaster<WandaEnvironment<?>> {
   
    private static final long serialVersionUID = 333828678645619526L;

    /**
     * Erzeugung aller fuer die Umgebung wichtigen Komponenten: Environment, WandaAgents, Obstacles
     *
     * @return WandaEnvironment[]
     */
    @Override
    @SuppressWarnings({"unchecked" })
    public WandaEnvironment<AbstractAgent2D<?>>[] generateRunnables(ParCollection params) {
       
        WandaEnvironment<AbstractAgent2D<?>> env = new WandaEnvironment<AbstractAgent2D<?>>(0 , params);
       
        // Rahmen (ca. 3000x3000)
        // Rahmen
        // horizontaler Balken unten
        env.addCollidingAgent(new ObstacleAgent(0, null, null), new Vector2D(0,1500), 0, new Vector2D(6,1));
        // horizontaler Balken oben
        env.addCollidingAgent(new ObstacleAgent(0, null, null), new Vector2D(0,-1500), 0, new Vector2D(6,1));
        // vertikaler Balken links
        env.addCollidingAgent(new ObstacleAgent(0, null, null), new Vector2D(-1510, 0), 90, new Vector2D(6,1));
        // vertikaler Balken rechts
        env.addCollidingAgent(new ObstacleAgent(0, null, null), new Vector2D(1510, 0), 90, new Vector2D(6,1));
       
        // Erzeugen der Agenten und Verhaltensuebertragung
        WandaAgent agent1 = new WandaAgent(0, env, params);
        agent1.addActuator(new aBerechnungSwarmSimulation());
       
        String fileName = SwarmScheduler.class.getPackage().getName().replace(".", "/")
                + "/swarmSimulation.xml";
       
        agent1.implantBrain(new MDL2eBrain<AbstractAgent2D<?>>(agent1, new File(fileName)));
        env.addCollidingAgent(agent1, new Vector2D(0,0), 80, new Vector2D(1,1));
       
        WandaAgent agent2 = new WandaAgent(0, env, params);
        agent2.addActuator(new aBerechnungSwarmSimulation());
        agent2.implantBrain(new MDL2eBrain<AbstractAgent2D<?>>(agent2, new File(fileName)));
        env.addCollidingAgent(agent2, new Vector2D(100,0), 80, new Vector2D(1,1));
       
        WandaAgent agent3 = new WandaAgent(0, env, params);
        agent3.addActuator(new aBerechnungSwarmSimulation());
        agent3.implantBrain(new MDL2eBrain<AbstractAgent2D<?>>(agent3, new File(fileName)));
        env.addCollidingAgent(agent3, new Vector2D(100,150), 80, new Vector2D(1,1));
       
        return new WandaEnvironment[] {env};
    }

    /**
     * Abfrage der ID
     *
     * @return ID
     */
    @Override
    public String id() {
        return ConstantsSimulation.DEFAULT_MASTER_SCHEDULER_ID + "-GruppeViWaWo.aufgabeVier";
    }
}
TOP

Related Classes of eas.users.ocScenarios.oclrss12.gruppe3.SwarmScheduler

TOP
Copyright © 2018 www.massapi.com. 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.