Package fr.utbm.gi.vi51.framework.environment

Examples of fr.utbm.gi.vi51.framework.environment.Environment


  /**
   * {@inheritDoc}
   */
  @Override
  protected AgentBody createBody(Environment in) {
    return new AgentBody(getAddress(),
        SIZE,
        5,            // max linear speed m/s
        .5,            // max linear acceleration (m/s)/s
        Math.PI/4,        // max angular speed r/s
        Math.PI/10);      // max angular acceleration (r/s)/s
View Full Code Here


      if (this.mouseTarget!=null) {
        allPercepts.add(new Perception(this.mouseTarget));
      }

      double bestDistance = Double.MAX_VALUE;
      AgentBody nearestBody = null;
     
      for(AgentBody b1 : getAgentBodies()) {
        if (b1!=agent) {
          double x2 = b1.getX();
          double y2 = b1.getY();
View Full Code Here

    List<AnimatAction> actions = new ArrayList<AnimatAction>(influenceList.size());
   
    // Compute actions
    for(int index1=0; index1<influenceList.size(); index1++) {
      MotionInfluence inf1 = influenceList.get(index1);
      AgentBody body1 = getAgentBodyFor(inf1.getEmitter());
      if (body1!=null) {
        Vector2d move;
        double rotation;
        if (inf1.getType()==DynamicType.STEEERING) {
          move = computeSteeringTranslation(body1, inf1.getLinearInfluence(), timeManager);
          rotation = computeSteeringRotation(body1, inf1.getAngularInfluence(), timeManager);
        }
        else {
          move = computeKinematicTranslation(body1, inf1.getLinearInfluence(), timeManager);
          rotation = computeKinematicRotation(body1, inf1.getAngularInfluence(), timeManager);
        }
       
        double x1 = body1.getX();
        double y1 = body1.getY();

        // Trivial collision detection
        for(int index2=index1+1; index2<influenceList.size(); index2++) {
          MotionInfluence inf2 = influenceList.get(index2);
          AgentBody body2 = getAgentBodyFor(inf2.getEmitter());
          if (body2!=null) {
            double x2 = body2.getX();
            double y2 = body2.getY();
                       
            double distance = new Vector2d(x2-x1,y2-y1).length();
           
            if (distance<(body1.getSize()+body2.getSize())) {
              move.set(0,0);
              break;
            }
          }
        }
       
        actions.add(new AnimatAction(body1, move, rotation));
       
      }
    }
   
    // Apply the actions
    for(AnimatAction action : actions) {
      AgentBody body = action.getObjectToMove();
      if (body!=null) {
        move(
            body,
            action.getTranslation(),
            action.getRotation());
View Full Code Here

   * @param o
   * @return the leader flag.
   */
  public boolean isLeader(SituatedObject o) {
    if (o instanceof AgentBody) {
      AgentBody body = (AgentBody)o;
      AgentAddress adr = body.getOwner();
      if (adr!=null) {
        String s = LocalizedString.get(Rabbit.class, "LEADER"); //$NON-NLS-1$
        return s!=null && s.equals(adr.getName());
      }
    }
View Full Code Here

      double x1 = agent.getX();
      double y1 = agent.getY();


      double bestDistance = Double.MAX_VALUE;
      AgentBody nearestBody = null;
     
      for(AgentBody b1 : getAgentBodies()) {
        if (b1!=agent) {
          double x2 = b1.getX();
          double y2 = b1.getY();
View Full Code Here

    List<AnimatAction> actions = new ArrayList<AnimatAction>(influenceList.size());
   
    // Compute actions
    for(int index1=0; index1<influenceList.size(); index1++) {
      MotionInfluence inf1 = influenceList.get(index1);
      AgentBody body1 = getAgentBodyFor(inf1.getEmitter());
      if (body1!=null) {
        Vector2d move;
        double rotation;
        if (inf1.getType()==DynamicType.STEEERING) {
          move = computeSteeringTranslation(body1, inf1.getLinearInfluence(), timeManager);
          rotation = computeSteeringRotation(body1, inf1.getAngularInfluence(), timeManager);
        }
        else {
          move = computeKinematicTranslation(body1, inf1.getLinearInfluence(), timeManager);
          rotation = computeKinematicRotation(body1, inf1.getAngularInfluence(), timeManager);
        }
       
        double x1 = body1.getX();
        double y1 = body1.getY();

        // Trivial collision detection
        for(int index2=index1+1; index2<influenceList.size(); index2++) {
          MotionInfluence inf2 = influenceList.get(index2);
          AgentBody body2 = getAgentBodyFor(inf2.getEmitter());
          if (body2!=null) {
            double x2 = body2.getX();
            double y2 = body2.getY();
                       
            double distance = new Vector2d(x2-x1,y2-y1).length();
           
            if (distance<(body1.getSize()+body2.getSize())) {
              move.set(0,0);
              break;
            }
           
          }
        }
       
        if(body1 instanceof LemmingBody)
        {

           
          LemmingBody body = (LemmingBody) body1;
          if(body.getIsActing())
          {
            if(body.getCurrentAction() == Action.DigVertically)
            {
              move.set(0,0);
            }
            else if(body.getCurrentAction() == Action.DigHorizontally)
            {
              move.set(1,0);
            }
          }
          actionApplier.doAction(body);
          actions.add(physicsEngine.Gravity(body, new AnimatAction(body, move, rotation)));
        }
       
      }
    }
   
    // Apply the actions
    for(AnimatAction action : actions) {
      AgentBody body = action.getObjectToMove();
      if (body!=null)
      {
       
        move(
            body,
View Full Code Here

        JOptionPane.YES_NO_OPTION,
        JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION;

    FrameworkGUI gui = new GUI(WORLD_SIZE_X, WORLD_SIZE_Y);
   
    Environment environment = new WorldModel(WORLD_SIZE_X, WORLD_SIZE_Y);
   
    FrameworkLauncher.launchEnvironment(environment, gui, EXECUTION_DELAY);

    Rabbit a = new Rabbit(steering) ;   
    FrameworkLauncher.launchAgent(a) ;
View Full Code Here

        JOptionPane.YES_NO_OPTION,
        JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION;

    FrameworkGUI gui = new GUI(WORLD_SIZE_X, WORLD_SIZE_Y);
   
    Environment environment = new WorldModel(WORLD_SIZE_X, WORLD_SIZE_Y);
   
    FrameworkLauncher.launchEnvironment(environment, gui, EXECUTION_DELAY);

    Lemming a = new Lemming(steering) ;   
    FrameworkLauncher.launchAgent(a) ;
View Full Code Here

    List<MotionInfluence> influenceList = new ArrayList<MotionInfluence>(influences);
    List<AnimatAction> actions = new ArrayList<AnimatAction>(influenceList.size());
   
    // Compute actions
    for(int index1=0; index1<influenceList.size(); index1++) {
      MotionInfluence inf1 = influenceList.get(index1);
      AgentBody body1 = getAgentBodyFor(inf1.getEmitter());
      if (body1!=null) {
        Vector2d move;
        double rotation;
        if (inf1.getType()==DynamicType.STEEERING) {
          move = computeSteeringTranslation(body1, inf1.getLinearInfluence(), timeManager);
          rotation = computeSteeringRotation(body1, inf1.getAngularInfluence(), timeManager);
        }
        else {
          move = computeKinematicTranslation(body1, inf1.getLinearInfluence(), timeManager);
          rotation = computeKinematicRotation(body1, inf1.getAngularInfluence(), timeManager);
        }
       
        double x1 = body1.getX();
        double y1 = body1.getY();

        // Trivial collision detection
        for(int index2=index1+1; index2<influenceList.size(); index2++) {
          MotionInfluence inf2 = influenceList.get(index2);
          AgentBody body2 = getAgentBodyFor(inf2.getEmitter());
          if (body2!=null) {
            double x2 = body2.getX();
            double y2 = body2.getY();
                       
            double distance = new Vector2d(x2-x1,y2-y1).length();
View Full Code Here

    List<MotionInfluence> influenceList = new ArrayList<MotionInfluence>(influences);
    List<AnimatAction> actions = new ArrayList<AnimatAction>(influenceList.size());
   
    // Compute actions
    for(int index1=0; index1<influenceList.size(); index1++) {
      MotionInfluence inf1 = influenceList.get(index1);
      AgentBody body1 = getAgentBodyFor(inf1.getEmitter());
      if (body1!=null) {
        Vector2d move;
        double rotation;
        if (inf1.getType()==DynamicType.STEEERING) {
          move = computeSteeringTranslation(body1, inf1.getLinearInfluence(), timeManager);
          rotation = computeSteeringRotation(body1, inf1.getAngularInfluence(), timeManager);
        }
        else {
          move = computeKinematicTranslation(body1, inf1.getLinearInfluence(), timeManager);
          rotation = computeKinematicRotation(body1, inf1.getAngularInfluence(), timeManager);
        }
       
        double x1 = body1.getX();
        double y1 = body1.getY();

        // Trivial collision detection
        for(int index2=index1+1; index2<influenceList.size(); index2++) {
          MotionInfluence inf2 = influenceList.get(index2);
          AgentBody body2 = getAgentBodyFor(inf2.getEmitter());
          if (body2!=null) {
            double x2 = body2.getX();
            double y2 = body2.getY();
                       
            double distance = new Vector2d(x2-x1,y2-y1).length();
View Full Code Here

TOP

Related Classes of fr.utbm.gi.vi51.framework.environment.Environment

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.