|
@@ -33,7 +33,7 @@ class LevelSpec:
|
|
|
newSpec = 1
|
|
newSpec = 1
|
|
|
self.specDict = {
|
|
self.specDict = {
|
|
|
'globalEntities': {},
|
|
'globalEntities': {},
|
|
|
- 'scenarios': [[{}, 1]],
|
|
|
|
|
|
|
+ 'scenarios': [{}],
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
assert hasattr(self, 'specDict')
|
|
assert hasattr(self, 'specDict')
|
|
@@ -76,12 +76,6 @@ class LevelSpec:
|
|
|
def getNumScenarios(self):
|
|
def getNumScenarios(self):
|
|
|
return len(self.specDict['scenarios'])
|
|
return len(self.specDict['scenarios'])
|
|
|
|
|
|
|
|
- def getScenarioWeights(self):
|
|
|
|
|
- weights = []
|
|
|
|
|
- for entry in self.specDict['scenarios']:
|
|
|
|
|
- weights.append(entry[1])
|
|
|
|
|
- return weights
|
|
|
|
|
-
|
|
|
|
|
def setScenario(self, scenario):
|
|
def setScenario(self, scenario):
|
|
|
assert scenario in range(0, self.getNumScenarios())
|
|
assert scenario in range(0, self.getNumScenarios())
|
|
|
self.scenario = scenario
|
|
self.scenario = scenario
|
|
@@ -141,7 +135,7 @@ class LevelSpec:
|
|
|
return self.specDict['globalEntities']
|
|
return self.specDict['globalEntities']
|
|
|
|
|
|
|
|
def privGetScenarioEntityDict(self, scenario):
|
|
def privGetScenarioEntityDict(self, scenario):
|
|
|
- return self.specDict['scenarios'][scenario][0]
|
|
|
|
|
|
|
+ return self.specDict['scenarios'][scenario]
|
|
|
|
|
|
|
|
def printZones(self):
|
|
def printZones(self):
|
|
|
"""currently prints list of zoneNum->zone name"""
|
|
"""currently prints list of zoneNum->zone name"""
|
|
@@ -319,7 +313,6 @@ class LevelSpec:
|
|
|
# structure names
|
|
# structure names
|
|
|
globalEntitiesName = 'GlobalEntities'
|
|
globalEntitiesName = 'GlobalEntities'
|
|
|
scenarioEntitiesName = 'Scenario%s'
|
|
scenarioEntitiesName = 'Scenario%s'
|
|
|
- scenarioWeightName = 'Scenarios'
|
|
|
|
|
topLevelName = 'levelSpec'
|
|
topLevelName = 'levelSpec'
|
|
|
def getPrettyEntityDictStr(name, dict, tabs=0):
|
|
def getPrettyEntityDictStr(name, dict, tabs=0):
|
|
|
def t(n):
|
|
def t(n):
|
|
@@ -369,21 +362,15 @@ class LevelSpec:
|
|
|
|
|
|
|
|
str += t(1)+'}\n'
|
|
str += t(1)+'}\n'
|
|
|
return str
|
|
return str
|
|
|
- def getPrettyScenarioWeightTableStr(tabs=0, self=self):
|
|
|
|
|
- def t(n):
|
|
|
|
|
- return (tabs+n)*tab
|
|
|
|
|
- str = t(0)+'%s = [\n' % scenarioWeightName
|
|
|
|
|
- for i in range(self.getNumScenarios()):
|
|
|
|
|
- str += t(1)+'[%s, %s],\n' % (scenarioEntitiesName % i,
|
|
|
|
|
- self.getScenarioWeights()[i])
|
|
|
|
|
- str += t(1)+']\n'
|
|
|
|
|
- return str
|
|
|
|
|
def getPrettyTopLevelDictStr(tabs=0):
|
|
def getPrettyTopLevelDictStr(tabs=0):
|
|
|
def t(n):
|
|
def t(n):
|
|
|
return (tabs+n)*tab
|
|
return (tabs+n)*tab
|
|
|
str = t(0)+'%s = {\n' % topLevelName
|
|
str = t(0)+'%s = {\n' % topLevelName
|
|
|
str += t(1)+"'globalEntities': %s,\n" % globalEntitiesName
|
|
str += t(1)+"'globalEntities': %s,\n" % globalEntitiesName
|
|
|
- str += t(1)+"'scenarios': %s,\n" % scenarioWeightName
|
|
|
|
|
|
|
+ str += t(1)+"'scenarios': [\n"
|
|
|
|
|
+ for i in range(self.getNumScenarios()):
|
|
|
|
|
+ str += t(2)+'%s,\n' % (scenarioEntitiesName % i)
|
|
|
|
|
+ str += t(2)+'],\n'
|
|
|
str += t(1)+'}\n'
|
|
str += t(1)+'}\n'
|
|
|
return str
|
|
return str
|
|
|
|
|
|
|
@@ -402,10 +389,6 @@ class LevelSpec:
|
|
|
self.privGetScenarioEntityDict(i))
|
|
self.privGetScenarioEntityDict(i))
|
|
|
str += '\n'
|
|
str += '\n'
|
|
|
|
|
|
|
|
- # add the scenario weight table
|
|
|
|
|
- str += getPrettyScenarioWeightTableStr()
|
|
|
|
|
- str += '\n'
|
|
|
|
|
-
|
|
|
|
|
# add the top-level table
|
|
# add the top-level table
|
|
|
str += getPrettyTopLevelDictStr()
|
|
str += getPrettyTopLevelDictStr()
|
|
|
|
|
|