diff --git a/scripts/HTN/Trees/Red/ConvoyUnit.xml b/scripts/HTN/Trees/Red/ConvoyUnit.xml index 0e482e3f891648f0b7779d3ce07ed24439f07e14..65ed14a46fb13bb104dfdba868e1e0780fe8fce9 100644 --- a/scripts/HTN/Trees/Red/ConvoyUnit.xml +++ b/scripts/HTN/Trees/Red/ConvoyUnit.xml @@ -151,9 +151,12 @@ if len(borg.redConvoysWaiting[state.getCurrentUnit().getName()])==0: randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) randSpd = 10.0 + (40.0 * randSpd) - destName = borg.redConvoyDest[state.getCurrentUnit().getName()] + destName = borg.redConvoyDest[state.getCurrentUnit().getName()][0] + del borg.redConvoyDest[state.getCurrentUnit().getName()][0] + SendUnitEventDelay(state.getCurrentUnit().getName(), "GoalTracker_MoveToPoint", ["CONVOY", randSpd, destName], borg.delay) borg.delay=1.0 + elif moveReason == "CONVOY": # setup off road cmdName="" @@ -226,11 +229,11 @@ from HTNBehaviors import SetRedUnitActivity borg.redUnitStatus[state.getCurrentUnitName()] = borg.redUnitStatus[state.getCurrentUnitName()] + 1 setupNum = _gt_activeNode.getVar("setupNum") -#printMessage("Setup completed", True) +printMessage("Setup completed rus: "+str(borg.redUnitStatus[state.getCurrentUnitName()])+" setupNum: "+str(setupNum), True) if borg.redUnitStatus[state.getCurrentUnitName()]==setupNum: rn = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) rn = (1.5 + rn * 2.5) * 14400.0 - rn = 60.0 + rn = 10.0 # SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_ConvoyReturn", [], rn) # printMessage("Convoy setup complete: "+str(state.getCurrentUnitName()), True) # borg.delay=0 @@ -298,9 +301,26 @@ SetRedUnitActivity(state.getCurrentUnitName(), "PACK_UP_AT_SITE") <Code IsFile="false">import cxxi.model.behavior.PythonUtilities as PythonUtilities from HTNBehaviors import SendEntityEventDelay -SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_ConvoyReturn", [], rn) -printMessage("Convoy pack up complete: "+str(state.getCurrentUnitName()), True) -borg.delay=0 + +if len(borg.redConvoyDest[state.getCurrentUnit().getName()])==0: + # no more destinations go home + SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_ConvoyReturn", [], rn) + printMessage("Convoy pack up complete: "+str(state.getCurrentUnitName()), True) + borg.delay=0 + +else: + # go to next destination + randSpd = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) + randSpd = 10.0 + (40.0 * randSpd) + + destName = borg.redConvoyDest[state.getCurrentUnit().getName()][0] + del borg.redConvoyDest[state.getCurrentUnit().getName()][0] + + # reset the setup count + borg.redUnitStatus[state.getCurrentUnitName()] = 0 + + SendUnitEventDelay(state.getCurrentUnit().getName(), "GoalTracker_MoveToPoint", ["CONVOY", randSpd, destName], borg.delay) + borg.delay=1.0 </Code> <Import /> </HTNNode> diff --git a/scripts/HTN/Trees/Red/RedForceCoordinator.xml b/scripts/HTN/Trees/Red/RedForceCoordinator.xml index 0d58722ea4e84386db4943eb46af13951e5a5d0f..24a8339c305d3a900faa07589152d15c79a92017 100644 --- a/scripts/HTN/Trees/Red/RedForceCoordinator.xml +++ b/scripts/HTN/Trees/Red/RedForceCoordinator.xml @@ -274,66 +274,66 @@ UtilityFuncsExp.scheduleEvent( 0.001, al) -#al = ArrayList() -#al.add("bigellipse") -#al.add("FIRE_CONTROL_RADAR") -#al.add("FIRE_CONTROL_RADAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -# -#UtilityFuncsExp.scheduleEvent( -# dm, -# info.getMyAssignedName(), -# "GoalTracker_CreateConvoy", -# 5, -# al) - -#al = ArrayList() -#al.add("bigbox") -#al.add("FIRE_CONTROL_RADAR") -#al.add("TARGET_ACQ_RADAR") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("SPT_VEH") -#al.add("TELAR") -#al.add("TELAR") -#al.add("TELAR") -# -#UtilityFuncsExp.scheduleEvent( -# dm, -# info.getMyAssignedName(), -# "GoalTracker_CreateConvoy", -# 10, -# al) +al = ArrayList() +al.add("bigellipse") +al.add("FIRE_CONTROL_RADAR") +al.add("FIRE_CONTROL_RADAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") + +UtilityFuncsExp.scheduleEvent( + dm, + info.getMyAssignedName(), + "GoalTracker_CreateConvoy", + 5, + al) + +al = ArrayList() +al.add("bigbox") +al.add("FIRE_CONTROL_RADAR") +al.add("TARGET_ACQ_RADAR") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("SPT_VEH") +al.add("TELAR") +al.add("TELAR") +al.add("TELAR") + +UtilityFuncsExp.scheduleEvent( + dm, + info.getMyAssignedName(), + "GoalTracker_CreateConvoy", + 10, + al) </Code> <Import /> </HTNNode> @@ -461,13 +461,26 @@ borg.redConvoysWaiting[tu.getName()] = [] # get the destination for the convoy # then move it to the back -destName = borg.redDestinations[0] -del borg.redDestinations[0] -borg.redDestinations.append(destName) +numDestinations = 1 +numDestChance = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0]) +if numDestChance > 0.75: + numDestinations = 3 +elif numDestChance > 0.25: + numDestinations = 2 + +#numDestinations = 3 + +convoyDests = [] +for n in range(numDestinations): + destName = borg.redDestinations[0] + del borg.redDestinations[0] + borg.redDestinations.append(destName) + convoyDests.append(destName) # set the convoys destination and formation # in the borg -borg.redConvoyDest[tu.getName()] = destName +#borg.redConvoyDest[tu.getName()] = destName +borg.redConvoyDest[tu.getName()] = convoyDests borg.redFormsByUnit[tu.getName()] = formName # randomize the speed @@ -477,7 +490,7 @@ randSpd = 10.0 + (40.0 * randSpd) # start the assembly SendUnitEventDelay(tu.getName(), "GoalTracker_Assemble", [randSpd], 1) -printMessage("Convoy move: "+str(tu.getName())+" DEST: "+destName, True) +printMessage("Convoy move: "+str(tu.getName())+" NUM DESTS: "+str(numDestinations), True) </Code> <Import /> </HTNNode> diff --git a/scripts/jump_start.py b/scripts/jump_start.py index 70a7958537d7e4d0a79ed707718ac0fa4f42c042..e1e4d96b94110c477fabdc8278a72e98a066a09c 100644 --- a/scripts/jump_start.py +++ b/scripts/jump_start.py @@ -56,26 +56,26 @@ UtilityFuncsExp.addGoal( None) # draw for number of fakeys -#numFakeConvoys = GetRandomInt(0, 2) -#fakeConvoys = [] -#if numFakeConvoys==1: -# fakeConvoys.append(fakeConvoy1) -#elif numFakeConvoys==2: -# fakeConvoys.append(fakeConvoy1) -# fakeConvoys.append(fakeConvoy2) +numFakeConvoys = GetRandomInt(0, 2) +fakeConvoys = [] +if numFakeConvoys==1: + fakeConvoys.append(fakeConvoy1) +elif numFakeConvoys==2: + fakeConvoys.append(fakeConvoy1) + fakeConvoys.append(fakeConvoy2) # create the fake convoys if any -#ctr = 10 -#for fakeConvoy in fakeConvoys: -# entityList = ConvertToJavaListRandom(fakeConvoy, 4, 25) -# fakeConvoyLeader = fakeConvoy[0] -# UtilityFuncsExp.addGoal( -# entityList.get(0), -# ctr, -# borg.goalPath + "Red/RandomMove.xml", -# [1, entityList, True], -# None) -# ctr = ctr + 10 +ctr = 10 +for fakeConvoy in fakeConvoys: + entityList = ConvertToJavaListRandom(fakeConvoy, 4, 25) + fakeConvoyLeader = fakeConvoy[0] + UtilityFuncsExp.addGoal( + entityList.get(0), + ctr, + borg.goalPath + "Red/RandomMove.xml", + [1, entityList, True], + None) + ctr = ctr + 10 # common trees for all entities or entities with specific combos for entity in PlayBoard.getSingleton().getAllEntities(): @@ -98,13 +98,13 @@ for entity in PlayBoard.getSingleton().getAllEntities(): None) # random movers -#ctr = 10 -#for vehicle in randomMoveVeh: -# UtilityFuncsExp.addGoal( -# vehicle, -# ctr, -# borg.goalPath + "Red/RandomMove.xml", -# [-1, None, False], -# None) -# ctr = ctr + 10 +ctr = 10 +for vehicle in randomMoveVeh: + UtilityFuncsExp.addGoal( + vehicle, + ctr, + borg.goalPath + "Red/RandomMove.xml", + [-1, None, False], + None) + ctr = ctr + 10