From c7cf0395f5cb6dc2cf5b5d5904fddeeb4cfc7076 Mon Sep 17 00:00:00 2001 From: "dereeves@nps.edu" <dereeves@nps.edu> Date: Fri, 30 Jul 2021 14:46:17 -0700 Subject: [PATCH] * moved speed parameter to jump_start for easier visibility --- scripts/HTN/Trees/Red/ConvoyUnit.xml | 33 +++++++++++++++---- scripts/HTN/Trees/Red/RedForceCoordinator.xml | 11 +++++-- scripts/jump_start.py | 12 +++++++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/scripts/HTN/Trees/Red/ConvoyUnit.xml b/scripts/HTN/Trees/Red/ConvoyUnit.xml index e2cea72..09a952b 100644 --- a/scripts/HTN/Trees/Red/ConvoyUnit.xml +++ b/scripts/HTN/Trees/Red/ConvoyUnit.xml @@ -182,8 +182,15 @@ 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) +# randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) +# randSpd = 10.0 + (40.0 * randSpd) + + # get a random speed + if borg.params_randSpdOverride > 0: + randSpd = borg.params_randSpdOverride + else: + randVal = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) + randSpd = borg.params_randSpdMin + (borg.params_randSpdVar * randVal) destName = borg.redConvoyDest[state.getCurrentUnit().getName()][0] del borg.redConvoyDest[state.getCurrentUnit().getName()][0] @@ -398,8 +405,15 @@ elif len(borg.redConvoyDest[state.getCurrentUnit().getName()])==0: else: # go to next destination - randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) - randSpd = 10.0 + (40.0 * randSpd) +# randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) +# randSpd = 10.0 + (40.0 * randSpd) + + # get a random speed + if borg.params_randSpdOverride > 0: + randSpd = borg.params_randSpdOverride + else: + randVal = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) + randSpd = borg.params_randSpdMin + (borg.params_randSpdVar * randVal) destName = borg.redConvoyDest[state.getCurrentUnit().getName()][0] del borg.redConvoyDest[state.getCurrentUnit().getName()][0] @@ -436,8 +450,15 @@ printMessage("Need to return", True) borg.redUnitStatus[state.getCurrentUnitName()]=0 -randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) -randSpd = 10.0 + (40.0 * randSpd) +#randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) +#randSpd = 10.0 + (40.0 * randSpd) + +# get a random speed +if borg.params_randSpdOverride > 0: + randSpd = borg.params_randSpdOverride +else: + randVal = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) + randSpd = borg.params_randSpdMin + (borg.params_randSpdVar * randVal) for m in state.getCurrentUnit().getMembers(): CreateNetworkMove( diff --git a/scripts/HTN/Trees/Red/RedForceCoordinator.xml b/scripts/HTN/Trees/Red/RedForceCoordinator.xml index 6a71840..cf8a806 100644 --- a/scripts/HTN/Trees/Red/RedForceCoordinator.xml +++ b/scripts/HTN/Trees/Red/RedForceCoordinator.xml @@ -534,8 +534,15 @@ borg.redConvoyDest[tu.getName()] = convoyDests borg.redFormsByUnit[tu.getName()] = formName # randomize the speed -randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) -randSpd = 10.0 + (40.0 * randSpd) +#randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) +#randSpd = 10.0 + (40.0 * randSpd) + +# get a random speed +if borg.params_randSpdOverride > 0: + randSpd = borg.params_randSpdOverride +else: + randVal = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) + randSpd = borg.params_randSpdMin + (borg.params_randSpdVar * randVal) # start the assembly SendUnitEventDelay(tu.getName(), "GoalTracker_Assemble", [randSpd], 1) diff --git a/scripts/jump_start.py b/scripts/jump_start.py index ff1c724..902e7d7 100644 --- a/scripts/jump_start.py +++ b/scripts/jump_start.py @@ -50,6 +50,18 @@ borg.params_redSetupTimeMin = 10 # amount of random time added to min time borg.params_redSetupTimeVar = 10 + +# here you can setup the random speed range +# currently ANY movement will use this random speed +# there is no differentiation between the random speed when +# moving to assemble vs the random speed when moving to attack +# values are m/s +borg.params_randSpdMin = 10 # this is the miniumum speed +borg.params_randSpdVar = 40 # this is the random amount to add to the minimum +# if this value is greater than zero it will substitute this value for all +# speeds instead of rolling for a random speed +borg.params_randSpdOverride = -1 + # used to for testing, these are normally all true # but if you want to just run a single convoy or specific # convoys you can turn them on and off here. -- GitLab