rendered paste body if ((time()-$time) >= 20 && $target =~ /^#rubik$/i && $text =~ /^[.!]((alg)?m|mega(minx)?)(\s(\d+))?/i) {
my $len = $5;
if ($len > 100) { $len = 100; } elsif ($len <= 0) { $len = 60; }
Irssi::signal_stop();
my @bits = (1,1,1,1,1,1,1,1,1,1,1,1);
my $chars = "ABCDEFabcdef2'";
my ($result,$rand);
for (my $i; $i < $len; $i++) {
$rand = int(rand(12));
while (!$bits[$rand]) { $rand = int(rand(12)); }
$bits[$rand] = 0;
# A B C D E F a b c d e f
# 0 1 2 3 4 5 6 7 8 9 10 11
#
# A - 0 1 1 1 1 1 a b c d e f
# B - 1 0 1 D E 1 a b c 1 1 f
# C - 1 1 0 1 E F a b c d 1 1
# D - 1 B 1 0 1 F a 1 c d e 1
# E - 1 B C 1 0 1 a 1 1 d e f
# F - 1 1 C D 1 0 a b 1 1 e f
# a - A B C D E F 0 1 1 1 1 1
# b - A B C 1 1 F 1 0 1 d e 1
# c - A B C D 1 1 1 1 0 1 e f
# d - A 1 C D E 1 1 b 1 0 1 f
# e - A 1 1 D E F 1 b c 1 0 1
# f - A B 1 1 E F 1 1 c d 1 0
my @mask = ("1#2#3#4#5","0#2#5#9#10","0#1#3#10#11","0#2#4#7#11","0#3#5#7#8","0#1#4#8#9","7#8#9#10#11","3#4#6#8#11","4#5#6#7#9","1#5#6#8#10","1#2#6#9#11","2#3#6#7#10");
# Ugly, yep. But it IS equal to that table above...
# my ($A, $B, $C, $D, $E, $F, $a, $b, $c, $d, $e, $f) = @bits;
#
# if ($rand == 0) { @bits = split //,"0" . "1" . "1" . "1" . "1" . "1" . $a . $b . $c . $d . $e . $f ; }
# if ($rand == 1) { @bits = split //,"1" . "0" . "1" . $D . $E . "1" . $a . $b . $c . "1" . "1" . $f ; }
# if ($rand == 2) { @bits = split //,"1" . "1" . "0" . "1" . $E . $F . $a . $b . $c . $d . "1" . "1"; }
# if ($rand == 3) { @bits = split //,"1" . $B . "1" . "0" . "1" . $F . $a . "1" . $c . $d . $e . "1"; }
# if ($rand == 4) { @bits = split //,"1" . $B . $C . "1" . "0" . "1" . $a . "1" . "1" . $d . $e . $f ; }
# if ($rand == 5) { @bits = split //,"1" . "1" . $C . $D . "1" . "0" . $a . $b . "1" . "1" . $e . $f ; }
# if ($rand == 6) { @bits = split //,$A . $B . $C . $D . $E . $F . "0" . "1" . "1" . "1" . "1" . "1"; }
# if ($rand == 7) { @bits = split //,$A . $B . $C . "1" . "1" . $F . "1" . "0" . "1" . $d . $e . "1"; }
# if ($rand == 8) { @bits = split //,$A . $B . $C . $D . "1" . "1" . "1" . "1" . "0" . "1" . $e . $f ; }
# if ($rand == 9) { @bits = split //,$A . "1" . $C . $D . $E . "1" . "1" . $b . "1" . "0" . "1" . $f ; }
# if ($rand == 10){ @bits = split //,$A . "1" . "1" . $D . $E . $F . "1" . $b . $c . "1" . "0" . "1"; }
# if ($rand == 11){ @bits = split //,$A . $B . "1" . "1" . $E . $F . "1" . "1" . $c . $d . "1" . "0"; }
@bits[split(/#/,$mask[$rand])] = (1,1,1,1,1);
$result .= substr($chars,$rand,1);
$rand = int(rand(4));
if ($rand && $rand != 3) { $result .= substr($chars,$rand+11,1); }
if ($rand == 3) { $result .= "2'"; }
$result .= " ";
}
$totals[7]++;
$time = time();
$server->command("msg #rubik Megaminx scramble #$totals[7]: $result");
save_counts();
}
}