a set of procedures for KI´s (genetic algorithms)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
Hurga
Enthusiast
Enthusiast
Posts: 148
Joined: Thu Jul 17, 2003 2:53 pm
Contact:

Post by Hurga »

Shame on me.. another bug

I happy that you use this procs. First that they are used, second, that these small bugs will appear...

Ok, some explanations for this bug ...

Epoche .. I used it first to select only the AI´s of the last epoche. In this approach I saved all AI´s used in this run (for each epoche in a seperate dir) and then select from them.

the for...next was a reminiscent from this ... I forgot to delete it.

the correct proc should be this

Code: Select all

Procedure.i gA_Init_Reproduction(Path_S.s) ; read all the previous genoms into LIST genAlgListAll(), returns <> 0 if ok
  Back_I.i
  Kumm_average_I.i
  s.s
  
  ; get the List of all genAlg´s with their Score and cummulate the Scores
  s = Right(#genAlgExtension, Len(#genAlgExtension)-1)
  
  If ExamineDirectory(0, Path_S, "*.*")
    While NextDirectoryEntry(0)
      If DirectoryEntryType(0) = #PB_DirectoryEntry_File
        If GetExtensionPart(DirectoryEntryName(0)) = s
          ; If StringField(DirectoryEntryName(0), 1, "-") = *Mutation\Name_S
          If Val(StringField(DirectoryEntryName(0), 1, "-")) > 0
            AddElement(genAlgListAll())
            genAlgListAll()\Path_S = Path_S + DirectoryEntryName(0)
            genAlgListAll()\Average_I = Val(StringField(DirectoryEntryName(0), 2, "-")) ; the score of the genAlg
            Kumm_average_I + genAlgListAll()\Average_I
            genAlgListAll()\AverageKumm_I = Kumm_average_I
          EndIf
          ; EndIf
        EndIf
      EndIf
    Wend
    FinishDirectory(0)
  EndIf
  
  If ListSize(genAlgListAll()) > 0
    Back_I = 1
    SortStructuredList(genAlgListAll(), #PB_Sort_Descending, OffsetOf(genAlgSelect\Average_I), #PB_Sort_Integer)
    Kummulated_GI = Kumm_average_I
  EndIf
  
  
  ProcedureReturn Back_I
EndProcedure
Post Reply