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;
}