/*+JMJ***************************************************************
 qdstarc.c - Quick and Dirty Pseudo Starfield Generator in C
 2011/2/4 David Meyer <papa@freeshell.org>
********************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define IROWS 24
#define ICOLS 69
#define FOPAC 0.07

int main( void )
{
  int r, c;
  float fmag;
  char s;

  srand( (unsigned) time( NULL ) );

  for ( r = 0; r < IROWS; r ++ )
    {
      for ( c = 0; c < ICOLS; c ++ )
	{
	  if ( ((float) rand() / (float) RAND_MAX) >= FOPAC )
	    printf( " " );
	  else
	    {
	      fmag = (float) rand() / (float) RAND_MAX;
	      if ( fmag < 0.5 )           s = '.';
	      else if ( fmag < 0.75 )     s = ',';
	      else if ( fmag < 0.875 )    s = 'o';
	      else if ( fmag < 0.9375 )   s = '*';
	      else if ( fmag < 0.96875 )  s = 'O';
	      else if ( fmag < 0.984375 ) s = '0';
	      else                        s = '@';
	      printf( "%c", s);
	    }
	}
      printf("\n");
    }
  exit(0);
}