#!/usr/pkg/bin/perl # starasc - Generate random ASCII star chart $popaque = 0.3; $field = 0; $lines = 24; $cols = 80; sub gaussian { my ($u1, $u2); my $w; my ($g1, $g2); do { $u1 = 2 * rand() - 1; $u2 = 2 * rand() - 1; $w = $u1*$u1 + $u2*$u2; } while ( $w >= 1 ); $w = sqrt( (-2 * log($w)) / $w ); $g2 = $u1 * $w; $g1 = $u2 * $w; return wantarray ? ($g1, $g2) : $g1; } $a = $b = $c = $d = $e = $f = $g = 0; for ( 0 .. int($lines * $cols / 2 * $popaque) ) { if ( rand(2) < 1 ) { print "."; $g++; } elsif ( rand(2) < 1 ) { print ","; $f++; } elsif ( rand(2) < 1 ) { print "*"; $e++; } elsif ( rand(2) < 1 ) { print "o"; $d++; } elsif ( rand(2) < 1 ) { print "O"; $c++; } elsif ( rand(2) < 1 ) { print "0"; $b++; } else { print "@"; $a++; } } print "\n$a:$b:$c:$d:$e:$f:$g\n";