All pastes #497504 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-19 21:58 UTC
rendered paste body
#!/usr/bin/perl

my @array = (1,0,1,1,1,1);
my $len = 25;
my $main;
my $chars = "UDFBLR";
for ($main = 0; $main < $len; $main++) {
  my $poss_moves;
  my $i;
  for (; $i < 6; $poss_moves += $array[$i++]) {}  # Find out how many possible moves there are
  my $rand = int(rand($poss_moves)) + 1; # Then generate a number depending on that number
  my $index;
  for ($i = 0; $i < $rand; $i += $array[$index++]) {} # Pick the array index of that set bit
  if (int($index/2) == 0) { @array[2 .. 5] = (1,1); print "G"; }
  if (int($index/2) == 1) { @array[0,1,4,5] = (1,1,1,1); }
  if (int($index/2) == 2) { @array[0 .. 3] = (1,1); }
  $array[$index] = 0;
  print $array[0] . $array[1] . $array[2] . $array[3] . $array[4] . $array[5];
  print substr($chars,$index-1,1) . " ";
}

print "\n";