Package trackerModule.core.rulestructure

Examples of trackerModule.core.rulestructure.Rule_Unit


   */
  String newRulesMoving( Rule_Unit sRule, String strPrevState, String strFirst, String strSecond, String Action, int time ){
    String strState1 = sRule.createUniqueStateName(Action + "At" + strFirst);
    String strState2 = sRule.createUniqueStateName("movingTo" + strSecond);
   
    Rule_Unit ru;
    //rule move to first location ////////////////////////////////////////////////////////
    Double posFirst[] = getRandomPosition(strFirst);
    ru = sRule.create();
    ru.setCondition("IsState", strPrevState);
    ru.setCondition("InArea", posFirst[0], posFirst[1]);
    ru.setAction("SetState", strState1, time);
    //not
    ru = sRule.create();
    ru.setCondition("IsState", strPrevState);
    ru.setCondition("NotInArea", posFirst[0], posFirst[1]);
    ru.setAction("MoveTo", posFirst[0], posFirst[1]);   
   
   
    //rule fishing at first location ////////////////////////////////////////////////////////
    ru = sRule.create();
    ru.setCondition("IsState", strState1);
    ru.setCondition("TimeFinished");
    ru.setAction("SetState", strState2 );
    //not
    ru = sRule.create();
    ru.setCondition("IsState", strState1);
    ru.setCondition("NotTimeFinished");
    ru.setAction(Action);
  
    return strState2;
  }
View Full Code Here


   * New rules.
   *
   * @return the rule_ unit
   */
  Rule_Unit newRules(){
    Rule_Unit shipsRule = (Rule_Unit) RDB.This().get("RDBROOT.SHIP_RULE");
    return shipsRule.create(getName());
  }
View Full Code Here

   * @return the string
   */
  String newRulesStarting(Rule_Unit sRule, String strFirstLocation, int time){
    Unit ship    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+getName());
    Unit location  = ship.get("Location");
    Rule_Unit ru = null;
   
    //rule start
    ru = sRule.create();
    ru.setCondition("IsGlobalTime", 1 );
    ru.setAction( "SetState", "waitingAt"+location.getData(0), time);
   
    //rule wait at a port //////////////////////////////////////////////////////// 
    ru = sRule.create();
    ru.setCondition("IsState", "waitingAt"+location.getData(0));
    ru.setCondition("TimeFinished");
    ru.setAction("SetState", "movingTo" + strFirstLocation );
    //not
    ru = sRule.create();
    ru.setCondition("IsState", "waitingAt"+location.getData(0));
    ru.setCondition("NotTimeFinished");
    ru.setAction("Waiting" );
   
    return "movingTo" + strFirstLocation;
   
  }
View Full Code Here

   * @param Action the action
   */
  void newRulesEnding( Rule_Unit sRule, String strPrevState, String strLocation, String Action ){
    String strState1 = sRule.createUniqueStateName(Action + "At" + strLocation);
   
    Rule_Unit ru;
    Double pos[] = getRandomPosition(strLocation);
   
    //rule move to third location ////////////////////////////////////////////////////////
    ru = sRule.create();
    ru.setCondition("IsState", strPrevState);
    ru.setCondition("InArea", pos[0], pos[1] );
    ru.setAction( "SetState", strState1, (int)(Math.random()*10)+30);
    //not
    ru = sRule.create();
    ru.setCondition("IsState", strPrevState);
    ru.setCondition("NotInArea", pos[0], pos[1]);
    ru.setAction("MoveTo", pos[0], pos[1]);
 
   
    //rule fishing at second location ////////////////////////////////////////////////////////
     ru = sRule.create();
    ru.setCondition("IsState", strState1);
    ru.setCondition("TimeFinished");
    ru.setAction("SetState", "end");
    //not
    ru = sRule.create();
    ru.setCondition("IsState", strState1);
    ru.setCondition("NotTimeFinished");
    ru.setAction("Wandering" );
  }
View Full Code Here

    String strState2 = sRule.createUniqueStateName("ContactingAt" + ship);
    String strState3 = sRule.createUniqueStateName("WanderingTo" + strFirst);
    String strState4 = sRule.createUniqueStateName("movingTo" + strSecond);
   
    
    Rule_Unit ru;
    //move to meeting area
    Double posFirst[] = getRandomPosition(strFirst);
    ru = sRule.create();
    ru.setCondition("IsState", strPrevState);
    ru.setCondition("InArea", posFirst[0], posFirst[1]);
    ru.setAction("SetState", strState1, 1);
    //not
    ru = sRule.create();
    ru.setCondition("IsState", strPrevState);
    ru.setCondition("NotInArea", posFirst[0], posFirst[1]);
    ru.setAction("MoveTo", posFirst[0], posFirst[1]);   
   
   
    //in meeting area, another ship arrived
    ru = sRule.create();
    ru.setCondition("IsState", strState1);
    ru.setCondition("Met", ship);
    ru.setAction("SetState", strState2, 1 );
    //not
    ru = sRule.create();
    ru.setCondition("IsState", strState1);
    ru.setCondition("Unmet", ship);
    ru.setAction("Wandering" )
   
   
    //to meet each other, move to each ship
    ru = sRule.create();
    ru.setCondition("IsState", strState2);
    ru.setCondition("Contact", ship);
    ru.setAction("SetState", strState3, time  );
    //not
    ru = sRule.create();
    ru.setCondition("IsState", strState2);
    ru.setCondition("Uncontact", ship);
    ru.setAction("Contacting", ship )
   
   
    //after meeting, wandering for a while
    ru = sRule.create();
    ru.setCondition("IsState", strState3);
    ru.setCondition("TimeFinished");
    ru.setAction("SetState", strState4 );
    //not
    ru = sRule.create();
    ru.setCondition("IsState", strState3);
    ru.setCondition("NotTimeFinished");
    ru.setAction("Wandering");
   
   
    return strState4;
  }
View Full Code Here

    Unit location  = ship.get("Location");
  
    //Determine tree ports scenario
    String strPrevState = "";
    int randSceario = getRandomOnThree();
    Rule_Unit sRule = null;
    if( randSceario == 0 ){//one port scenario
      int randPort = getRandomOnThree();
      String strFirst = World.This().mapNearestFishingArea.get(location.getData()).get(randPort);
      sRule = newRules();
      strPrevState = newRulesStarting( sRule, strFirst, getStartTimeForFishingShip() );
View Full Code Here

    }
   
    //System.out.println(location.getData() + " to " + destination.getData());
    //System.out.println(arrayWayPoints.toString());
   
    Rule_Unit sRule = null;
   
    String strPrevState = "";
    String strPrev = "";
    int i = 0;
    for( String str : arrayWayPoints ){
View Full Code Here

    arrayWayPoints = World.This().spaUnusualArea.getShortestPath(location.getData(), destination.getData());
   
    //System.out.println(location.getData() + " to " + destination.getData());
    //System.out.println(arrayWayPoints.toString());
   
    Rule_Unit sRule = null;
   
    String strPrevState = "";
    String strPrev = "";
    int i = 0;
    for( String str : arrayWayPoints ){
View Full Code Here

    arrayWayPoints = World.This().spaUnusualArea.getShortestPath(location.getData(), destination.getData());
   
    //System.out.println(location.getData() + " to " + destination.getData());
    //System.out.println(arrayWayPoints.toString());
   
    Rule_Unit sRule = null;
   
    String strPrevState = "";
    String strPrev = "";
    int i = 0;
    for( String str : arrayWayPoints ){
View Full Code Here

   
    //System.out.println(location.getData() + " to " + destination.getData());
    //System.out.println(arrayWayPoints1.toString());
    //System.out.println(arrayWayPoints2.toString());
   
    Rule_Unit sRule = null;
   
    String strPrevState = "";
    String strPrev = "";
    int i = 0;
    int turning = 10; // how many patrol
View Full Code Here

TOP

Related Classes of trackerModule.core.rulestructure.Rule_Unit

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.