diff --git a/scripts/HTN/Trees/Red/EntityLogger.xml b/scripts/HTN/Trees/Red/EntityLogger.xml index 1e1192281d1a01b231264375c79c55b869432f60..c5c3f77316cc565ffe1602e1e43d019d78c32693 100644 --- a/scripts/HTN/Trees/Red/EntityLogger.xml +++ b/scripts/HTN/Trees/Red/EntityLogger.xml @@ -35,6 +35,7 @@ borg.redLoggerInterval = 60 # goal tracker events #goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_Event") goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_LogInfo") +goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_LogMsg") </Code> <Import /> </HTNNode> @@ -86,6 +87,41 @@ LogGenericMsg.logMsg( #printMessage("TEST LOG", True) SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogInfo", [], borg.redLoggerInterval) +</Code> + <Import /> + </HTNNode> + </HTNNode> + <HTNNode AllowMsg="true" Name="isGoalTracker_LogMsg" Type="DEFAULT"> + <Parent>printGoalTrackerEvent</Parent> + <Code IsFile="false">if state.getLastTrigger().startswith("doGoalTracker_LogMsg"): + _htn_precon_ret=1 +</Code> + <Import /> + <HTNNode AllowMsg="true" Name="logMsg" Type="INTERRUPT"> + <Parent>isGoalTracker_LogInfo</Parent> + <Code IsFile="false">import mtry.cxxi.model.MtryLog.LogGenericMsg as LogGenericMsg +from HTNBehaviors import SendEntityEventDelay +from HTNBehaviors import IsTransmitting +from HTNBehaviors import ConvertJavaToList + +# event params +params = state.getLastTriggerParams()[0] + +# logger name +logName = params.get(0) +# logger header +logHeader = params.get(1) + +# the data is put into a java list so get it back out into a python list +logData = ConvertJavaToList(params.get(2)) + +# log the message +LogGenericMsg.logMsg( + logName, + logHeader, + info.getMySelf(), + logData) + </Code> <Import /> </HTNNode> diff --git a/scripts/HTN/Trees/Red/RedForceCoordinator.xml b/scripts/HTN/Trees/Red/RedForceCoordinator.xml index eebd4e5dec75c2c1781f372fef4994d69e3c9a70..d7f50423cca2ded53aefa3054e9c1aa616eda7a1 100644 --- a/scripts/HTN/Trees/Red/RedForceCoordinator.xml +++ b/scripts/HTN/Trees/Red/RedForceCoordinator.xml @@ -371,6 +371,7 @@ goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_ReclaimCo <Parent>isCreateConvoy</Parent> <Code IsFile="false">import mtry.cxxi.model.HierarchicalTaskNetwork.PythonUtilities.PythonUnit as PythonUnit from HTNBehaviors import SendEntityEventDelay +from HTNBehaviors import ConvertToJavaList # an index for the convoy convoyIndex = _gt_activeNode.getVar("convoyIndex") @@ -410,6 +411,11 @@ _gt_activeNode.putVar("convoyIndex", convoyIndex+1) # go to making the convoy move (still in this tree) SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_MoveConvoy", [tu.getName(), formName], 1) + +# log data +logData = [ info.getMyAssignedName(), state.getCurrentUnitName() ] +SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["TestLog", "NAME\tUNIT_NAME", ConvertToJavaList(logData)], 0) + </Code> <Import /> </HTNNode> diff --git a/scripts/HTNBehaviors.py b/scripts/HTNBehaviors.py index 1dcc4386152bc86e7b7d424953a378e4a7ba0823..691bbc41b9486a32edfe1377ef7fae270760c4fa 100644 --- a/scripts/HTNBehaviors.py +++ b/scripts/HTNBehaviors.py @@ -67,6 +67,12 @@ def GetRandomPoint(): return destName +# returns a true or false depending on whether the drawn number is +# less than the probability +def GetRandomChance(probability): + int_num = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) + return int_num < probability + def _InitBorgInternal(): global borg diff --git a/scripts/jump_start.py b/scripts/jump_start.py index e1e4d96b94110c477fabdc8278a72e98a066a09c..97ae3cb9483d77d21ebe1e5c51db5be0541dce4f 100644 --- a/scripts/jump_start.py +++ b/scripts/jump_start.py @@ -5,6 +5,7 @@ from HTNBehaviors import SendEntityEvent from HTNBehaviors import ConvertToJavaList from HTNBehaviors import ConvertToJavaListRandom from HTNBehaviors import GetRandomInt +from HTNBehaviors import GetRandomChance from SATracker import SATracker @@ -26,6 +27,10 @@ printMessage("SA Inited = "+str(borg.saTracker.retrieveData(info.getMyAssignedNa borg.goalPath = "HTN/Trees/" entityName = "RFC" +# get bool value for if we're in attack mode or not +# 0.5 maps to a 50% chance of attack mode being true +borg.attackMode = GetRandomChance(0.5) + randomMoveVeh = ["Entity_303", "Entity_304", "Entity_305", "Entity_306", "Entity_307", "Entity_308", "Entity_309", "Entity_310", "Entity_311", "Entity_312", "Entity_313", "Entity_314", "Entity_315", "Entity_316", "Entity_317",