A Program correction

GRMorton@aol.com
Fri, 14 Jul 1995 19:26:21 -0400

As is my policy, when someone points out some error I have made, I announce
it in the interest of the truth. I feel it is more important to be correct
in the long run than to avoid embarassing admissions of error. I make lots
of errors.

In a private note, Robert Van de Water has pointed out one error in the old
basic code. He is correct about this error. But it was fixed when I made
the executable files because the darn thing wouldn't run right in Pascal if I
hadn't fixed it.

The error concerns the starting point on each cycle of the variable y and x.
In the basic code it was not reset on each cycle. This is because the code
evolved from Sierpinski's Gasket code. In that code, the starting point of x
and y are totally unimportant. Regardless of the starting point, the gasket
is generated. In the code I presented, the morphology of the daughter depends
partly on the starting point. It was not until the Pascal code was generated
that I saw that it was important to reset x,y each cycle. The executables do
not have this error.

I would like to thank Robert for catching that in the Basic code, and I will
no longer post that code. The whole reason I have posted the code before is
so that others can critique it. Robert did. Below is the Pascal code which
made the executable evolve.exe.

This error in no way affects the philosophical conclusions I have drawn from
the program. Philosophically, the error is equivalent to having added an
additional pair of elements to the genome. Instead of an 8 byte genome, the
basic code really acted like a 10 byte genome with three bytes mutated each
cycle. Unless someone finds a similar error in the Pascal code, it should
act like a 8 byte genome with only 1 mutation each cycle. In short I don't
think this error is a major flaw nor does it affect the analogy.

glenn

Pascal Program Code
{$N+,E+}

program evolve;
uses crt,graph,dos;
label 10;
type xt=array[1..4] of real;
yt=array[1..4] of real;
op=array[1..75,1..75] of integer;
np=array[1..75,1..75] of integer;
var

Z1,
Z2,
Z4,
Z5,
A2,r,
B2,x,y,cros,crosfin,sx,sy,sxy,syy,sxx : Real;
oldp:op;
newp:np;
I,X1,Y1,X2,Y2,X3,Y3,x4,y4,A1,B1,b,c,
J,f1,ij,count,
K,a,cnt,cnt2 : LONGINT;
ans,s : string[20];
code:integer;
xa:xt;
ya:yt;

procedure draw(x1,y1:real);
begin
line(round(x1),round(y1),round(x1),round(y1));
end;

procedure rcircle(x0,y0,r : real);
begin
circle(round(x0),round(y0),round(r))
end;

procedure paint(x0,y0 : real;fc,bc:integer);
begin
setfillstyle(solidfill,fc);
floodfill(round(x0),round(y0),bc);
end;

function always : integer;
begin
always := 4;
end;

procedure initializegraphics;
var gd,gm:integer;
count,errorcode,lowmode,himode:integer;
autodetect :pointer;

begin
{Autodetect := @always;}
Gd := detect;
gm:=3;
initgraph(gd,gm,'');
{ getmoderange(gd,lowmode,himode);
setgraphmode(himode);
errorcode:=graphresult;
if errorcode<>grok then
begin
writeln('graphics error:',grapherrormsg(errorcode));
writeln('program aborted...');
halt(1);
end;}

END;
procedure start;
begin
Xa[1]:=0;xa[2]:=0;xa[3]:=0;xa[4]:=0;Ya[1]:=0;ya[2]:=0;ya[3]:=0;ya[4]:=0;
x:=0.84;y:=0.84;cnt:=0;cnt2:=0;
setcolor(lightblue);
line(0,0,0,450);line(0,0,600,0);line(600,0,600,450);line(600,450,0,450);

line(75,0,75,450);line(150,0,150,450);line(225,0,225,450);line(300,0,300,450);

line(375,0,375,450);line(450,0,450,450);line(525,0,525,450);

line(0,75,600,75);line(0,150,600,150);line(0,225,600,225);line(0,300,600,300);

line(0,375,600,375);setcolor(red);outtextxy(0,460,'press any key to
quit');

for i:=1 to 75 do
begin
for j:=1 to 75 do
begin
newp[i,j]:=0;
oldp[i,j]:=0;
end;
end;
end;

procedure loop;
begin
For I := 0 to 5000 do
begin
a:= RANDOM(4)+1;
y:=abs(cos(2*(y-ya[a])/3));x:=abs(cos(2*(x-xa[a])/3));
{

PUTPIXEL(40*round(40*x)+cnt*75+30,40*round(y)+cnt2*75+30,white);}
if ((70*x+cnt*75)>cnt*75) and ((70*x)<(cnt*75+75)) then
begin
if ((70*y+cnt2*75)>(cnt2*75)) and ((70*y)<(cnt2*75+75)) then
begin
PUTPIXEL(round(70*x+cnt*75),round(70*y+cnt2*75),white);
newp[round(70*x),round(70*y)]:=1;
end;
end;
end;

end;