Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 20 in printed book and digital formats -- plus a one-year subscription (beginning with 21.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Recent issues

Article Preview

Buy Now

Issue 2.1


Genetic Algorithms, Part 2

Improve Your Computer's Sex Life

Issue: 2.1 (August/September 2003)
Author: Matt Neuburg
Author Bio: Matt Neuburg is the author of REALbasic: The Definitive Guide, and a member of the editorial board of REALbasic Developer.
Article Description: No description available.
Article Length (in bytes): 8,492
Starting Page Number: 34
Article Number: 2116
Resource File(s):

Download Icon 2116.zip Updated: 2013-03-11 19:07:57

Related Web Link(s):


Excerpt of article text...

Last month's column introduced genetic algorithms, where we simulate Mendelian/Darwinian evolution as a way of solving some problem. We start with a population of individuals, each endowed with some DNA. We regard each individual's DNA as a possible answer to our problem, and we rank it according to how good an answer it is. We take the individuals with the best DNA and mate them, generating a new population, repeating the process again and again.

The "problem" in this case, you may recall, was to arrive at a good sequence of bytes, where "goodness" is defined as follows. Every byte is translated into an alphanumeric character or a space, thus arriving at a series of words. A word like "9BJ6" is bad, and reduces the cumulative value of the DNA by multiplying it by 0.8. A word comprising entirely digits, like "46", adds to the cumulative value of the DNA a number of points equal to its length. The word "M" doubles the cumulative value of the DNA. A word like "AG12589" -- the letter "A" followed by only non-digits followed by only digits -- multiplies the cumulative value of the DNA by the numeric value of its digits part. Although this is not an earth-shattering problem, it makes for a good example, since it turns out that in 100 generations, the computer is able to optimize its byte sequence very strongly with respect to these rules.

As I said last time, the heart of the algorithm is a loop that looks a lot like one's idea of real-life evolution:

Core loop:


...End of Excerpt. Please purchase the magazine to read the full article.