Skip to content
Snippets Groups Projects
Commit 23003f25 authored by Reeves, David E's avatar Reeves, David E
Browse files

* random speeds

parent 850bddee
No related branches found
No related tags found
No related merge requests found
......@@ -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"
......
......@@ -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(),
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment