def main(): input = "R:/massive/test/cdl/man/CDL/man_relative.cdl" output = "R:/scratch/out.cdl" agentSpec = CDLReader.read(input, ["fuzzy"]) fileHandle = open(output, "w") CDLWriter.write(fileHandle, agentSpec) fileHandle.close() os.system('xdiff.exe %s %s' % (input, output))
def testOutputChannels(self): ''' Test that the Genotype calculates the right output channels. ''' input = "R:/massive/testdata/cdl/man/CDL/embedded_simple.cdl" agentSpec = CDLReader.read(input, CDLReader.kEvolveTokens) geno = Genotype.Genotype(agentSpec) expectedChannels = [ "ty", "rx", "ry", "rz", "height", "leg_length", "shirt_map", "walk", "walk_45L", "walk_sad", "walk->walk_45L", "walk->walk_sad", "walk_45L->walk", "walk_45L->walk_sad", "walk_sad->walk", "walk_sad->walk_45L", "walk:rate", "walk_45L:rate", "walk_sad:rate" ] self.assertEqual(sorted(expectedChannels), sorted(geno.outputChannels()))
def agentSpec(self, key, type = ""): '''Key is either an agent type or the absolute path to a CDL file.''' agentSpec = None try: agentSpec = self._agentSpecMap[key] except: if os.path.isfile(key): agentSpec = CDLReader.read(key) if type: # By default an agent's type will be determined by the # object keyword in the CDL file. However if the agent is # being loaded as part of a Massive Scene, the agent type # will be determined by the group keyword in the MAS file. # This prevents agent type name clashes as the MAS file # agent type includes an id unique within the Massive # scene. # agentSpec.agentType = type self.addAgentSpec(agentSpec) else: raise return agentSpec
def testFuzzy(self): ''' Read and write fuzzy nodes from a test file. Read the fuzzy nodes from a test file, write them out again, and compare the two files. They should be identical except for a comment at the beginning of the files. ''' input = "R:/massive/testdata/cdl/man/CDL/fuzzy_nodes.cdl" agentSpec = CDLReader.read(input, ["fuzzy"]) nodes = agentSpec.brain.nodes() self.assertEqual(30, len(nodes)) fileHandle = open(self.scratchFile, "w") CDLWriter.write(fileHandle, agentSpec) fileHandle.close() inputHandle = open(input, "r") scratchHandle = open(self.scratchFile, "r") inputLines = inputHandle.readlines()[1:] scratchLines = scratchHandle.readlines()[1:] inputHandle.close() scratchHandle.close() self.assertEqual(inputLines, scratchLines)
def setUp(self): input = "R:/massive/testdata/cdl/man/CDL/noise.cdl" self.agentSpec = CDLReader.read(input, CDLReader.kEvolveTokens) self.geno = Genotype.Genotype(self.agentSpec) self.geno.rand = TestUtil.NotRandom()
def setUp(self): input = "R:/massive/testdata/cdl/man/CDL/output.cdl" self.agentSpec = CDLReader.read(input, CDLReader.kEvolveTokens) self.geno = Genotype.Genotype(self.agentSpec) self.geno.rand = TestUtil.NotRandom()