SHOW:
|
|
- or go back to the newest paste.
| 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. |
| 9 | + | time.sleep(1.8) # Wait while the disk writes them. |
| 10 | ||
| 11 | # Run 12 simulators to test the children. | |
| 12 | - | for sim in range(12) : |
| 12 | + | f_fork_procs( 12 ) |
| 13 | - | args = "-o{}{}.{} -c{}".format(fitFileName, sim , fitFileExt , sim)
|
| 13 | + | |
| 14 | - | RunSimulator(simuFileName , args ) |
| 14 | + | |
| 15 | while not ospathALLexists(fitFileName,fitFileExt,12) : | |
| 16 | time.sleep(0.4) | |
| 17 | ||
| 18 | - | time.sleep(1.0) |
| 18 | + | |
| 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 | - | time.sleep(0.3) |
| 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) |
| 32 | + | time.sleep(0.8) # Wait between deleting weights.dat and recreating it. |
| 33 | ||
| 34 | # return the list of fitnesses | |
| 35 | return( allfitlocal ) |