Results 1 to 16 of 16

Thread: Why isn't this Genetic Algorithm working?

Threaded View

  1. #1
    wossname
    Guest

    Hi.

    Being a newbie to C++, I thought I had better get used to using strings, so I have written a Genetic Algorithm to come up with a random string of characters which it then mutates and "breeds" from, ultimately to match a target phrase.

    I have a number (#defined as num) of such offspring.

    Now, when there are only 2 offspring in each iteration, the program runs perfectly. But as soon as I use a different number...

    #define num 4

    the program doesn't even seem to bother running through the algorithm.

    I am utterly lost as to why this should be the case since i have used the macro name throughout the program to denote the loop parameters and array offsets.

    If anyone can give me a hand in trying to locate the reason for this problem, then I'd be much obliged.

    The program compiles in the DJGPP compiler (in which it was written).

    The program doesn't crash as such, it just exits early for some weird reason.

    Don't worry about the weird target phrase, its a shakespearian quote. If you have read "The Blind Watchmaker" it will make sense!

    Please feel free to criticise the code to your heart's content, I need all the help I can get!

    The file should be attached here

    |
    |

    V
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width