Advertisement
Guest User

FitnessGlobal_Get

a guest
Dec 30th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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(1.8)  # Wait while the disk writes them.
  10.    
  11.     # Run 12 simulators to test the children.
  12.     f_fork_procs( 12 )
  13.  
  14.     # Wait for all the simulators to finish
  15.     while not ospathALLexists(fitFileName,fitFileExt,12) :
  16.         time.sleep(0.4)
  17.        
  18.     # Read all fitnesses of the children from disk
  19.     allfitlocal = []
  20.     for f in range(12) :
  21.         FfF = Fitness_from_File( fitFileName, fitFileExt , f )
  22.         allfitlocal.append ( FfF )
  23.        
  24.     time.sleep(0.3)     # Wait for the drive to close the files.
  25.            
  26.     # Cleanup temporary files.
  27.     os.remove(weightsFileName)
  28.     for ctf in range(12) :
  29.         clean = "{}{}.{}".format( fitFileName, ctf , fitFileExt )
  30.         os.remove( clean )
  31.  
  32.     time.sleep(0.8)   # Wait between deleting weights.dat and recreating it.
  33.    
  34.     # return the list of fitnesses
  35.     return( allfitlocal )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement