Advertisement
Guest User

FitnessGlobal_Get()

a guest
Dec 30th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. # * #
  2. def FitnessGlobal_Get( Cchildlist ):
  3.     weightsFileName = 'weights.dat'
  4.     fitFileName     = 'fits'
  5.     fitFileExt      = 'dat'
  6.     simuFileName    = 'AppRagdollDemo.exe'
  7.  
  8.     Send_Global_Weights_ToFile( Cchildlist , weightsFileName)
  9.     time.sleep(2.1)  # Wait while the disk writes them.
  10.    
  11.     # Run 12 simulators to test the children.
  12.     for sim in range(12) :
  13.         args = "-o{}{}.{} -c{}".format(fitFileName, sim , fitFileExt , sim)
  14.         RunSimulator(simuFileName , args )    
  15.  
  16.     # Wait for all the simulators to finish
  17.     while not ospathALLexists(fitFileName,fitFileExt,12) :
  18.         time.sleep(1.0)
  19.        
  20.     # Read all fitnesses of the children from disk
  21.     allfitlocal = []
  22.     for f in range(12) :
  23.         FfF = Fitness_from_File( fitFileName, fitFileExt , f )
  24.         allfitlocal.append ( FfF )
  25.     time.sleep(0.3)
  26.            
  27.     # Cleanup temporary files.
  28.     os.remove(weightsFileName)
  29.     for ctf in range(12) :
  30.         clean = "{}{}.{}".format( fitFileName, ctf , fitFileExt )
  31.         os.remove( clean )
  32.     time.sleep(0.8)  
  33.    
  34.     # return the list of fitnesses
  35.     return( allfitlocal )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement