!
! Random number generator tester
!

Constant usualIter = 20000;
Constant time = 50;
Global iterations = 0;
Global height = 0;

Array count --> 70;

[ fart;
    rtrue;
];

[ randomise x y z;
    for (x=0:x<usualIter:)
    {
	for (z=0:z<time:z++)
	{
	    x++;
	    y = random(69);
	    count-->y = count-->y+1;
	}
	iterations = iterations + time;
	height = $24-->0;
	display();
	@read_char 1 1 fart -> z;
    }
];

[ display x y z q largest;
    @split_window 30;
    @set_window 1;
    @erase_window 1;

    largest = 1;
    for (x=0: x<70: x++)
    {
	if (count-->x > largest)
	    largest = count-->x;
    }

    @set_cursor 1 1;
    print iterations, " iterations";

    for (x=0: x<70: x++)
    {
	z = (count-->x*(height-2))/largest;
	q = 3+(x%6);
	@set_colour q q;
	for (y=0: y<=z: y++)
	{
	    q = height-y;
	    @set_cursor q x;
	    print (char) '#';
	}
    }
    @set_colour 1 1;
    @set_cursor 1 1;
];

[ Main x;
    for (x=0:x<70:x++)
	count-->x = 0;

    height = $24-->0;
    
    while (1)
    {
    	randomise();
    	display();
	@read_char -> x;
    }
];
