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

* code for setup practice

parent 3c1d162e
No related branches found
No related tags found
No related merge requests found
......@@ -180,6 +180,14 @@ if len(borg.redConvoysWaiting[state.getCurrentUnit().getName()])==0:
cmdName = info.getMyAssignedName()
else:
cmdName = state.getCurrentCommander().getAssignedName()
# calculate how long on station they should be
rn = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0])
rn = (1.5 + rn * 2.5) * 14400.0
rn = 1
borg.redTimeOnStation[state.getCurrentUnitName()]=rn
printMessage("SETTING TOS "+str(state.getCurrentUnitName()), True)
SendEntityEvent(cmdName, "GoalTracker_ConvoySetup", [])
borg.delay=1.0
# log data
......@@ -345,8 +353,25 @@ if state.isCommander():
<Code IsFile="false">import cxxi.model.behavior.PythonUtilities as PythonUtilities
from HTNBehaviors import SendEntityEventDelay
# reset the setup count
borg.redUnitStatus[state.getCurrentUnitName()] = 0
if borg.redTimeOnStation[state.getCurrentUnitName()] &gt; 1: # check against 1 because at least one setup always occurs
# time on station hasn't elapsed, keep practicing setup
cmdName=""
if state.isCommander():
cmdName = info.getMyAssignedName()
else:
cmdName = state.getCurrentCommander().getAssignedName()
if len(borg.redConvoyDest[state.getCurrentUnit().getName()])==0:
SendEntityEvent(cmdName, "GoalTracker_ConvoySetup", [])
printMessage("Setting up again: "+str(cmdName), True)
borg.redTimeOnStation[state.getCurrentUnitName()]=borg.redTimeOnStation[state.getCurrentUnitName()]-1
# reset the setup count
borg.redUnitStatus[state.getCurrentUnitName()] = 0
elif 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)
......@@ -360,9 +385,9 @@ else:
destName = borg.redConvoyDest[state.getCurrentUnit().getName()][0]
del borg.redConvoyDest[state.getCurrentUnit().getName()][0]
# reset the setup count
borg.redUnitStatus[state.getCurrentUnitName()] = 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
......
......@@ -24,7 +24,10 @@ borg.redUnitActivityTime=dict()
borg.redEntityActivityOverride=dict()
borg.redDestinations=["PATH_DEST1", "PATH_DEST2","PATH_DEST3","PATH_DEST4","PATH_DEST5","PATH_DEST6","PATH_DEST7","PATH_DEST8","PATH_DEST9"]
borg.randomMoveStartTime=0</Code>
borg.randomMoveStartTime=0
borg.redTimeOnStation=dict()
</Code>
<Import />
</HTNNode>
<HTNNode AllowMsg="true" Name="createFormations" Type="DEFAULT">
......@@ -274,66 +277,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>
......@@ -471,7 +474,7 @@ if numDestChance &gt; 0.75:
elif numDestChance &gt; 0.5:
numDestinations = 2
#numDestinations = 3
numDestinations = 1
convoyDests = []
for n in range(numDestinations):
......
......@@ -70,17 +70,17 @@ elif numFakeConvoys==2:
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():
......@@ -103,13 +103,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
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