You are not logged in.
Pages: 1
I don't know what gave me this idea, but here it is anyway... a simple multiple choice game that presents a package description followed by 4 package names. All you have to do is pick the right name.
By default it uses locally installed packages. You can pass it the option "--all" to use all packages from the sync database. Passing it a number will change the number of default options.
It keeps track of the number of correct answers and winning streaks. It's not difficult because many of the package descriptions mention the package. Some of them are tricky though, and it can be interesting to see the descriptions of some of the things on your system.
At the end of the day though, this is basically pointless.
name_that_pkg.pl
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
my $info = (grep {$_ eq '--all'} @ARGV) ? `pacman -Si` : `pacman -Qi`;
push @ARGV, 4;
my $a = (grep {($_ =~ m/^\d+$/) and $_ > 0} @ARGV)[0];
my @list;
my $name;
$info =~ s/\n\s\s+/ /g;
foreach my $line (split "\n", $info)
{
if ($line =~ m/^Name\s+:\s+(\S+)/)
{
$name = $1;
}
elsif ($line =~ m/^Description\s+:\s+(.+)$/)
{
push @list, "$name : $1";
}
}
my $n = scalar @list;
my ($correct, $total, $streak, $best_streak) = (0,0,0,0);
my $ans;
while (1)
{
my $c_name;
my $c_desc;
my @names;
my $c = int(rand($a));
for (my $i=0; $i<$a; $i++)
{
my ($name,$desc) = &split_line($list[int(rand($n))]);
if (grep {$name eq $_} @names)
{
$i--;
next;
}
push @names, $name;
if ($i == $c)
{
($c_name,$c_desc) = ($name,$desc);
$c_desc =~ s/\Q$c_name\E/*/gi;
}
}
print "description: $c_desc\n";
my $j = 1;
foreach my $name (@names)
{
print "$j) $name\n";
$j++;
}
print "x) exit\n";
print "answer: ";
my $ans = <STDIN>;
chomp $ans;
last if (lc($ans) eq 'x');
$total++;
print "\n";
if ($ans == $c + 1)
{
$correct++;
$streak++;
$best_streak = $streak if ($streak > $best_streak);
print color ('bold green'), 'correct', color ('reset'), "\n";
}
else
{
$streak = 0;
print color ('bold red'), 'incorrect', color ('reset'), " (answer: $c_name)\n";
}
print "current score: $correct/$total ",int(100 * $correct / $total),"%\n";
print "current streak: $streak\n";
print "best streak: $best_streak\n\n";
}
sub split_line
{
return ($_[0] =~ m/^(\S+) : (.+?)\s*$/);
}
Last edited by Xyne (2009-02-24 19:08:51)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
great game,
maybe you should out-regex package names from descriptions:
description: Libassuan is the IPC library used by some GnuPG related software
1) libassuan
2) binutils
3) fontconfig
4) thunar-archive-plugin
x) exit
☃ Snowman ☃
Offline
May be you can strip the name of the package from the description....See below!!
description: xbindkeys allows you to launch shell commands with your keyboard or your mouse under X Window
1) dosfstools
2) xbindkeys
3) xdialog
4) virtualbox-ose
x) exit
answer:
Offline
Well if package names would follow arch packaging guidelines, this wouldn't happen
Offline
Most of slackware users would really appreciate this game.
Offline
Have you considered seeking therapy for having too much time on your hands?
Offline
this is awesome, haha. I must agree that you have too much time on your hands though
Last edited by evr (2009-02-24 17:40:14)
Offline
Well if package names would follow arch packaging guidelines, this wouldn't happen
I guess we had to wait for Xyne's game to really understand the full value of this guideline.
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
It's not that I have too much time on my hands (the opposite, actually), just that I'm easily sidetracked. This only took 10-15 minutes anyway.
I've updated the script to replace the package name with "*", which works well enough for most descriptions with some notable exceptions:
description: * is a language and envi*onment fo* statistical computing and g*aphics
1) shared-mime-info
2) gen-init-cpio
3) r
4) medit
Last edited by Xyne (2009-02-24 19:13:17)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
description: Gives a fake root environment, useful for building packages as a non-privileged user
1) fakeroot
x) exit
This game is too easy
flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)
Offline
This game is awesome!! Thanks, Xyne Pretty easy, yeah, but still funny.
And it's sweet that it also lets one find problematic names/descriptions in packages too
Offline
Definitely a fun game, learned a few new things about some libraries that had been installed as deps.
dnyy in IRC & Urban Terror
Offline
Pages: 1