I am using ActionScript 2 (yeah, I know, it's outdated, but I'm so very accustomed to it), and I am trying to make a program similar to that of the Weasel Program by Richard Dawkins in the 1987 documentary "The Blind Watchmaker". Basically, a random string of letters is generated, with a target phrase it is trying to reach, and each time a letter is correct, it stays that way, and the rest of the string carries on guessing until the word is correct.
So far, I've only gotten the string to generate random letters over and over again until it eventually just happens to get the target phrase and stop guessing. It's working fine, but all attempts to get it to work similar to the Weasel Program have failed. Here is the code I am using to make it guess over and over.
var a:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var alphabet:Array = a.split("");
var randomLetter:String = "";
for (var i = 0; i < newLength; i++)
randomLetter += alphabet[Math.floor(Math.random() * alphabet.length)];
_root.onEnterFrame = function()
var finalString:String = "CRAIG";
var finalArray:Array = finalString.split("");
var weaselArray:Array = weasel_txt.text.split("");
if (weasel_txt.text != finalString)
weasel_txt.text = generateRandomString(5);
The "weasel_txt" is a dynamic text box with that instance name. That's all the stage is set up with. I'm hoping somebody can get back to me as soon as possible.