diff --git a/scripts/HTN/Trees/Red/ConvoyUnit.xml b/scripts/HTN/Trees/Red/ConvoyUnit.xml index 28b6cd9cf4075810944a2a937a04a4338905ef84..d6d5618c964f81f3dd0a6c14caa5a32cdb05abaf 100644 --- a/scripts/HTN/Trees/Red/ConvoyUnit.xml +++ b/scripts/HTN/Trees/Red/ConvoyUnit.xml @@ -68,7 +68,8 @@ goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_ConvoyPac printMessage("Assembling...", True) -SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_MoveToPoint", ["ASSEMBLE", "ASSEMBLY_LOCATION"], 5.0) +randSpd = state.getLastTriggerParams()[0].get(0) +SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_MoveToPoint", ["ASSEMBLE", randSpd, "ASSEMBLY_LOCATION"], 5.0) borg.delay=1.0 borg.redUnitStatus[state.getCurrentUnitName()] = 0 @@ -92,18 +93,19 @@ params = state.getLastTriggerParams()[0] wps = [] for i in range(params.size()): - if i>0: + if i>1: wps.append(params.get(i)) _gt_activeNode.putVar("moveReason", params.get(0)) -_gt_activeNode.putVar("moveDestination", wps[len(wps)-1]) +_gt_activeNode.putVar("moveDestination", wps[0]) +randSpd = params.get(1) borg.redConvoysWaiting[state.getCurrentUnit().getName()].append(info.getMyAssignedName()) CreateNetworkMove( state.getCurrentLocation(), wps, - 3.0, + randSpd, None, info.getMyAssignedName(), info.getMyAssignedName(), @@ -111,7 +113,7 @@ CreateNetworkMove( "MOVE", borg.delay) borg.delay+=5.0 -printMessage("Starting move: "+str(wps), True) +printMessage("Starting move: "+str(wps)+" Spd: "+str(randSpd), True) ##################################################### # set activity to log @@ -131,6 +133,7 @@ if _gt_activeNode.getVar("moveReason") == "CONVOY": <Parent>printGoalTrackerEvent</Parent> <Code IsFile="false">from HTNBehaviors import SendUnitEventDelay from HTNBehaviors import SendEntityEvent +import cxxi.model.behavior.PythonUtilities as PythonUtilities borg.redConvoysWaiting[state.getCurrentUnit().getName()].remove(info.getMyAssignedName()) @@ -141,8 +144,12 @@ if len(borg.redConvoysWaiting[state.getCurrentUnit().getName()])==0: if moveReason == "ASSEMBLE": # let the unit know TODO: THis should probably come from the RFC + + randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) + randSpd = 10.0 + (40.0 * randSpd) + destName = borg.redConvoyDest[state.getCurrentUnit().getName()] - SendUnitEventDelay(state.getCurrentUnit().getName(), "GoalTracker_MoveToPoint", ["CONVOY", destName], borg.delay) + SendUnitEventDelay(state.getCurrentUnit().getName(), "GoalTracker_MoveToPoint", ["CONVOY", randSpd, destName], borg.delay) borg.delay=1.0 elif moveReason == "CONVOY": # setup off road @@ -300,13 +307,19 @@ borg.delay=0 <Parent>isGoalTracker_ConvoyReturn</Parent> <Code IsFile="false">printMessage("Need to return", True) +# TODO: This should probably use the moveToPoint methods + borg.redUnitStatus[state.getCurrentUnitName()]=0 + +randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) +randSpd = 10.0 + (40.0 * randSpd) + for m in state.getCurrentUnit().getMembers(): CreateNetworkMove( m.getPhysicalState().getGroundTruthLocation(), ["ASSEMBLY_LOCATION"], - 3.0, + randSpd, None, m.getAssignedName(), info.getMyAssignedName(), @@ -315,6 +328,8 @@ for m in state.getCurrentUnit().getMembers(): borg.delay) borg.delay+=5.0 +printMessage("Returning", True) + ##################################################### # set activity to log borg.redUnitActivity[state.getCurrentUnitName()]="RETURN_TO_GARRISON" diff --git a/scripts/HTN/Trees/Red/RandomMove.xml b/scripts/HTN/Trees/Red/RandomMove.xml index fc0460fa3fc40dc162b175d1a63776f0c50b12c8..2c366235b052f0f73f5503f3ccd7d03d54705ca4 100644 --- a/scripts/HTN/Trees/Red/RandomMove.xml +++ b/scripts/HTN/Trees/Red/RandomMove.xml @@ -66,6 +66,7 @@ goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_SelectNex <HTNNode AllowMsg="false" Name="moveToDestination" Type="INTERRUPT"> <Parent>isGoalTrackerEvent</Parent> <Code IsFile="false">from HTNBehaviors import CreateNetworkMove +import cxxi.model.behavior.PythonUtilities as PythonUtilities params = state.getLastTriggerParams()[0] @@ -77,10 +78,14 @@ for i in range(params.size()): _gt_activeNode.putVar("moveReason", params.get(0)) _gt_activeNode.putVar("moveDestination", wps[len(wps)-1]) +randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) +randSpd = 10 + (40 * randSpd) +printMessage("CIV VEH Random Speed: " + str(randSpd), True) + CreateNetworkMove( state.getCurrentLocation(), wps, - 3.0, + randSpd, None, info.getMyAssignedName(), info.getMyAssignedName(), diff --git a/scripts/HTN/Trees/Red/RedForceCoordinator.xml b/scripts/HTN/Trees/Red/RedForceCoordinator.xml index a09593ab11928e216cbaa60b0f2ffeb075701f6a..c7bd0492de197bd612cab89c4cd0ac036fda986e 100644 --- a/scripts/HTN/Trees/Red/RedForceCoordinator.xml +++ b/scripts/HTN/Trees/Red/RedForceCoordinator.xml @@ -451,6 +451,7 @@ formName = borg.redFormsByUnit[unit.getName()] <Parent>isMoveConvoy</Parent> <Code IsFile="false">import cxxi.model.knowledge.group.holders.NewUnitHolder as NewUnitHolder from HTNBehaviors import SendUnitEventDelay +import cxxi.model.behavior.PythonUtilities as PythonUtilities unitName = state.getLastTriggerParams()[0].get(0) formName = state.getLastTriggerParams()[0].get(1) @@ -467,7 +468,12 @@ borg.redDestinations.append(destName) borg.redConvoyDest[tu.getName()] = destName borg.redFormsByUnit[tu.getName()] = formName -SendUnitEventDelay(tu.getName(), "GoalTracker_Assemble", [], 1) + +randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) +randSpd = 10.0 + (40.0 * randSpd) + + +SendUnitEventDelay(tu.getName(), "GoalTracker_Assemble", [randSpd], 1) printMessage("Convoy move: "+str(tu.getName())+" DEST: "+destName, True) </Code>