March Madness - Random Number Test

Random numbers are not always random and in fact can actually be predictable. In working on yesteredays sort demo which used random numbers to generate the patern to sort, it was interesting to watch the resultant slope of the graph. It was not alwasy the same, which it should not be, but had a fairly even spread most of the time.

To test this further, I use the random() function to generate an X and Y value and plot the dot. Recuring patterns would indicate non-randomness, this was not the case so the random number is fiarly good.

//*******************************************************************************


#include	<math.h>

#include	<string.h>
#include	<stdio.h>
#include	<stdlib.h>
#include	<WProgram.h>

#include	"HardwareSerial.h"

#include	"UnivGraphicsHW_Defs.h"
#include	"UnivGraphicsLib.h"
#include	"UnivGraphicsHardware.h"




long	gPixelCount;

//*******************************************************************************
void setup()
{

	Serial.begin(9600);
	Serial.println("Random Demo");
	
	UnivGraphicsLib_Init();

	gPixelCount	=	0;
}

//*******************************************************************************
void loop()
{
int		xx;
int		yy;

	xx	=	random(0, 127);
	yy	=	random(0, 64);
	
	GrahicsHW_SetPixel(xx, yy, kCOLOR_Black);

	gPixelCount++;
	
	if (gPixelCount > 8000)
	{
		delay(5000);
		erasescreen();
		gPixelCount	=	0;
	}
}