All pastes #497586 Raw Edit

Anonymous

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

my @array = (1,1,1,1,1,1);
my $len = 25;
my $main;
my $chars = "UDFBLR2'";
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
  #print $index . " ";
  $index--;
  if (int($index/2) == 0) { @array[2 .. 5] = (1,1,1,1); }
  if (int($index/2) == 1) { @array[0,1,4,5] = (1,1,1,1); }
  if (int($index/2) == 2) { @array[0 .. 3] = (1,1,1,1); }
  $array[$index] = 0;
  $rand = int(rand(3));
   print substr($chars,$index,1) . (($rand) ? substr($chars,$rand+5,1) : "") . " ";
}

print "\n";