From: kv07@IASTATE.EDU (Warren Vonroeschlaub)
Subject: Variations on a frog.
Reply-To: kv07@IASTATE.EDU (Warren Vonroeschlaub)
Organization: Ministry of Silly Walks
Date: Thu, 15 Oct 1992 22:00:56 GMT

  If you remember Cunchy Frog's original string evolving program you will
recognize this as a variation on it.  The recent talk about sex allowing better
convergence to an optimum made me wonder how much better.  There is also the
question I have been struggling with recently about how much muatation and
selection is best.

  The following program was the result.  Sexual or asexual creatures can be used
to evolve any desired string.  Also mutation and selection pressure can be
adjusted.  This allows a variety of interesting results (ie sex works well if
mutation is rare, but badly if mutation common).

  The program has the following parameters:

  A string to evolve to must be present.  If it contains spaces or special
symbols it must be surrounded by double quotes ("").  The string may contain any
alphanumeric character.  No control codes or special characters can be entered. 
For example "If we took the bones out, it wouldn't be crunchy." is a valid
string.  Some characters a special commands in various operating systems. 
obviously these can cause problems.

  The s option toggles sex.  -s means sex should not be used, +s means it
should.  The default is +s.

  The -mNUM option sets the mutation rate.  The number NUM tells how often
mutation should occur.  -m5 means 1 in 5 characters are mutated in each string. 
The larger the number the less often mutation occurs.  The number must be an
integer between 1 and 32,000.  -m10 is the default.

  The -kNUM option sets the selection pressure.  The number NUM represents the
percent of the population which survives to reproduce.  -k30 means that 30% of
the population reproduces, while 70% of the population dies out.  -k50 is the
default.

  This program was dashed off while I was waiting for my laundry to dry.  I know
it can be improved, and welcome any comments.  Also, part of the code came to me
in a dream last night.  This is not my normal method for programming, so I
apologize if parts are a bit unreadable.

  To get the program, save this post in a file (ie "evo"), then, at the prompt,
type
 %uudecode evo
 %cc -O -o evolve evolve.c
 %rm evo

----Start of code----
begin 644 evolve.c
M(VEN8VQU9&4@/'-T9&QI8BYH/@HC:6YC;'5D92 \<W1R:6YG+F@^"@HC:69N
M9&5F(%]?5%520D]#7U\*(V1E9FEN92!R86YD;VUI>F4H*2!S<F%N9#0X*&=E
M='!I9"@I*0HC9&5F:6YE(')A;F1O;2AX*2 H;')A;F0T."@I("4@>"D*(V5N
M9&EF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5U;:6YD
M97A=*3L*?0H*:6YT(&UA:6XH:6YT(&%R9V,L8VAA<B J87)G=EM=*7L*("!I
M;G0@:6YD97@L<V5X/3$L;6%X:V5E<#TU,"QG96YE<F%T:6]N/3 ["B @8VAA
M<B!W86YT6TU!6%-44DE.1UT["@H@(&EF*&%R9V,\,BE["B @("!P=71S*")#
M;VUM86YD.B!E=F]L=F4@7")S=')I;F=<(B!;*R\M<UT@6RUM3E5-72!;+6M.
M54U=(BD["B @("!E>&ET*#$I.PH@('T*("!F;W(H:6YD97@],3MI;F1E>#QA
M<F=C.RLK:6YD97@I"B @("!I9BAA<F=V6VEN9&5X75LP73T])RTG*7L*(" @
M(" @:68H87)G=EMI;F1E>%U;,5T]/2=S)RD@<V5X/3$["B @(" @(&EF*&%R
M9W9;:6YD97A=6S%=/3TG;2<I(&UU=&%T93TH:6YT*2!A=&]L*"9A<F=V6VEN
M9&5X75LR72D["B @(" @(&EF*&%R9W9;:6YD97A=6S%=/3TG:R<I(&UA>&ME
M97 ]*&EN="D@871O;"@F87)G=EMI;F1E>%U;,ETI.PH@(" @?65L<V4@:68H
M87)G=EMI;F1E>%U;,%T]/2<K)RE["B @(" @(&EF*&%R9W9;:6YD97A=6S%=
M/3TG<R<I('-E>#TP.PH@(" @?65L<V4@<W!R:6YT9BAW86YT+&%R9W9;:6YD
M97A=*3L*("!R86YD;VUI>F4H*3L*("!S=W)A;CUS=')L96XH=V%N="D["B @
M9F]R*&EN9&5X/3 [:6YD97@\34%80U)%05154D4[*RMI;F1E>"D@;6%K97)A
M;BAI;F1E>"QS=W)A;BD["B @9&]["B @("!F;W(H:6YD97@],#MI;F1E>#Q-
M05A#4D5!5%5213LK*VEN9&5X*0H@(" @("!S8V]R95MI;F1E>%T]9&ES="AE
M8V]L;V=Y6VEN9&5X72QW86YT*3L*(" @('-O<G0H*3L*(" @(&EF*&UA>&ME
M97 ^*$U!6$-214%455)%+S(I*0H@(" @("!F;W(H:6YD97@];6%X:V5E<#MI
M;F1E>#Q-05A#4D5!5%5213LK*VEN9&5X*0H):68H<V5X*2!C;VUB:6YE*&EN
M9&5X+6UA>&ME97 L:6YD97@M;6%X:V5E<"LQ+&EN9&5X*3L*"65L<V4@8V]P
M>2AI;F1E>"UM87AK965P+&EN9&5X*3L*(" @(&5L<V4*(" @(" @9F]R*&EN
M9&5X/3 [:6YD97@\34%80U)%05154D4M;6%X:V5E<#LK*VEN9&5X*0H):68H
M<V5X*2!C;VUB:6YE*&EN9&5X+&EN9&5X*S$L:6YD97@K;6%X:V5E<"D["@EE
M;'-E(&-O<'DH:6YD97@M;6%X:V5E<"QI;F1E>"D["B @(" K*V=E;F5R871I
M;VX["B @("!I9B@H9V5N97)A=&EO;B4Q,"D]/3$I('!U=',H96-O;&]G>5LP
M72D["B @?7=H:6QE*'-C;W)E6S!=(3TP*3L*("!P=71S*&5C;VQO9WE;,%TI
M.PH@('!R:6YT9B@B179O;'9E9"!I;B E9"!G96YE<F%T:6]N<RY<;B(L9V5N
997)A=&EO;BD["B @<F5T=7)N*# I.PI]"B!G
 
end
----End of code----

 |  __L__   *******************************
-|-  ___    * Warren Kurt vonRoeschlaub   *
 |  | o |   * kv07@iastate.edu            *
 |/ `---'   * Iowa State University       *
/|   ___    * Math Department             *
 |  |___|   * 400 Carver Hall             *
 |  |___|   * Ames, IA  50011             *
 J  _____   *******************************
Newsgroups: talk.origins