I spent a few hours cooking up something in Perl (my preferred language), using the MediaWiki::Bot module from CPAN. To run this:
1. Fire up the CPAN shell using the "cpan" command, and force-install the module:
Code: Select all
$ cpan
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v2.11)
Enter 'h' for help.
cpan[1]> force install MediaWiki::Bot
Reading '~/.cpan/Metadata'
Database was generated on Mon, 09 Jan 2017 01:29:02 GMT
[...]
2. Save Chris C.'s still_list.txt file in a suitable directory.
3. Save the following script in the same directory, as e.g. applebot.pl -- better yet, get it from Github:
Code: Select all
#!/usr/bin/perl
###############
### MODULES ###
###############
# preliminaries
use Modern::Perl '2014';
use English;
use utf8; # script itself is in UTF-8
# core modules
use Getopt::Long;
use Term::ANSIColor qw/:constants/;
# non-core modules
use Data::Dumper; # for debugging
use File::Slurp;
use MediaWiki::Bot;
use PerlIO::Util; # for ->push_layer on *STDOUT etc
##############################
### CONFIGURATION DEFAULTS ###
##############################
# run anonymously?
# NOTE: MediaWiki::Bot 5.006003 is unable to login to newer wikis, due to
# the module's lack of maintenance and the frequent and
# backwards-incompatible changes to the MediaWiki API.
our $be_anonymous = 1;
# debugging level to be passed to MediaWiki::Bot (0, 1 or 2).
our $debug_level = 0;
# filename for Chris C's still_list.txt; should be downloaded from
# https://github.com/ceebo/glider_synth/blob/master/still_list.txt
our $still_list_txt = "still_list.txt";
# category to fetch pages from; suggested values are "Strict still lifes" or
# "Still lifes".
our $category = "Strict still lifes";
# username to use.
our $username = "Apple Bot";
# password to use. Don't specify this here; pass it on the command line.
our $password => undef;
####################################################
### NO NEED TO CHANGE ANYTHING BEYOND THIS POINT ###
####################################################
# autoflush STDOUT
$OUTPUT_AUTOFLUSH = 1;
# also write console output to log file
*STDOUT->push_layer(tee => 'output.applebot.log');
# process options
GetOptions(
"password|p=s" => \$password,
"username|u=s" => \$username,
"anonymous!" => \$be_anonymous,
) or usage();
# create a bot object we'll be using to operate
our $applebot = MediaWiki::Bot->new({
# assert => 'bot', # uncomment once Apple Bot has a bot flag on the wiki.
operator => 'Apple Bottom',
# protocol => 'https', # does not currently work due to an invalid SSL certificate
protocol => 'http',
host => 'conwaylife.com',
debug => $debug_level,
});
# call MAIN routine and exit
exit MAIN();
####################
### MAIN ROUTINE ###
####################
sub MAIN {
my $starting_time = time;
say "Starting up at ", BRIGHT_WHITE, scalar localtime($starting_time), RESET, ".";
# this hash will hold information on our objects.
my $objects = {};
# read Chris C.'s list
print "Reading Chris C.'s list... ";
my @ceebo_lines = read_file($still_list_txt);
# process Chris C.'s list
foreach my $ceebo_line (@ceebo_lines) {
# split line into object number (e.g. 4.1), apgcode (e.g. xs4_33)
# and glider count (e.g. 2)
my ($number, $apgcode, $synthesis) = split /\s+/, $ceebo_line;
# record this object in our objects hash.
$objects->{$apgcode} = {
'number' => $number,
'ceebo_synthesis' => $synthesis,
};
}
say GREEN, "done", RESET;
# log in to the wiki
unless($be_anonymous) {
# make sure user provided username and password.
if(($username // "") eq "" or ($password // "") eq "") {
die "No username/password specified!";
}
print "Logging in to the LifeWiki as ", BRIGHT_WHITE, $username, RESET, "... ";
$applebot->login({
username => "Apple Bot",
password => "",
}) or die "Login failed";
say GREEN, "done", RESET;
}
# get list of page titles
print "Getting list of strict still lifes... ";
my @page_titles = $applebot->get_pages_in_category(
"Category:$category",
{
max => 0, # return all results
}
);
say GREEN, "done", RESET;
foreach my $page_title (@page_titles) {
# get page text
print "Getting wikitext for ${page_title}... ";
my $wikitext = $applebot->get_text($page_title);
# this could conceivably happen if a page gets deleted after we
# fetched the list of page titles.
unless(defined $wikitext) {
say BRIGHT_RED, "page does not exist!";
next;
}
say GREEN, "done", RESET;
# apgcode and synthesis
my $apgcode = undef;
my $synthesis = undef;
# attempt to extract glider synthesis
if($wikitext =~ m/synthesis\s*=\s*([^\s\|]+)/g) {
$synthesis = $1;
# say "\tSynthesis: ", BRIGHT_WHITE, $synthesis, RESET;
# } else {
# say "\tNo synthesis found";
}
# attempt to extract apgcode
if($wikitext =~ m/\{\{LinkCatagolue\|[^\}]*(xs(\d+)_([0-9a-z]+))/g) {
$apgcode = $1;
# say "\tapgcode: ", BRIGHT_WHITE, $apgcode, RESET;
# } else {
# say "\tNo apgcode found";
}
# did we extract an apgcode?
if(defined $apgcode) {
# yes; remember page title and synthesis count
$objects->{$apgcode}->{'page_title'} = $page_title;
$objects->{$apgcode}->{'wiki_synthesis'} = $synthesis;
}
}
# Find objects we could improve (sorted by page title, only taking into
# account objects that are on the wiki in the first place).
foreach my $apgcode (sort { $objects->{$a}->{'page_title'} cmp $objects->{$b}->{'page_title'} } grep { exists $objects->{$_}->{'page_title'} } keys %$objects) {
# if we have the wiki_synthesis (sub)hash key, the object was found
# on the wiki (but the associated value may be undefined if no
# glider synthesis count was extracted). Same for Chris C.'s
# synthesis.
if(exists $objects->{$apgcode}->{'wiki_synthesis'} and exists $objects->{$apgcode}->{'ceebo_synthesis'}) {
# extract synthesis counts, for convenience
my ($wiki_synthesis, $ceebo_synthesis, $page_title) =
map {
$objects->{$apgcode}->{$_}
} ("wiki_synthesis", "ceebo_synthesis", "page_title");
# is the object without a listed synthesis on the wiki?
if(not defined $wiki_synthesis) {
say BRIGHT_WHITE, $page_title, RESET, " has no synthesis on the wiki, but a ", BRIGHT_WHITE, $ceebo_synthesis, RESET, " glider synthesis in Chris C.'s list.";
# or is the wiki synthesis worse than Chris C.'s?
} elsif($wiki_synthesis > $ceebo_synthesis) {
say BRIGHT_WHITE, $page_title, RESET, " has a ", BRIGHT_WHITE, $wiki_synthesis, RESET, " glider synthesis on the wiki, but a ", BRIGHT_WHITE, $ceebo_synthesis, RESET, " glider synthesis in Chris C.'s list.";
}
}
}
# log out of the wiki
unless($be_anonymous) {
print "Logging out... ";
$applebot->logout();
say GREEN, "done", RESET;
}
say "Finished at ", BRIGHT_WHITE, scalar localtime(time), RESET, ".";
# success!
return 0;
}
###################
### SUBROUTINES ###
###################
# print usage information
sub usage {
print <<ENDOFUSAGE;
Usage: $0 [options]
Options:
--anonymous Do not login (default). Negate with --no-anonymous.
--username=<...> Use specified username for logging in.
--password=<...> Use specified password for logging in.
ENDOFUSAGE
exit 1;
}
Code: Select all
Starting up at Mon Jan 9 18:46:30 2017.
Reading Chris C.'s list... done
Getting list of strict still lifes... done
Getting wikitext for Aircraft carrier... done
Getting wikitext for Amphisbaena... done
Getting wikitext for Barge... done
Getting wikitext for Barge with long tail... done
Getting wikitext for Bee hat... done
Getting wikitext for Beehive... done
Getting wikitext for Beehive and cap... done
Getting wikitext for Beehive and dock... done
Getting wikitext for Beehive and table... done
Getting wikitext for Beehive at beehive... done
Getting wikitext for Beehive at loaf... done
Getting wikitext for Beehive bend tail... done
Getting wikitext for Beehive with nine... done
Getting wikitext for Beehive with tail... done
Getting wikitext for Bi-cap... done
Getting wikitext for Bi-loaf 1... done
Getting wikitext for Bi-loaf 2... done
Getting wikitext for Bi-loaf 4... done
Getting wikitext for Bi-pond... done
Getting wikitext for Big S... done
Getting wikitext for Block... done
Getting wikitext for Block and cap... done
Getting wikitext for Block and dock... done
Getting wikitext for Block and two tails... done
Getting wikitext for Block on table... done
Getting wikitext for Boat... done
Getting wikitext for Boat on aircraft... done
Getting wikitext for Boat on snake... done
Getting wikitext for Boat with hooked tail... done
Getting wikitext for Boat with long tail... done
Getting wikitext for Boat with very long tail... done
Getting wikitext for Boat-ship-tie... done
Getting wikitext for Boat-tie... done
Getting wikitext for Bookends... done
Getting wikitext for BTS... done
Getting wikitext for Canoe... done
Getting wikitext for Cap and dock... done
Getting wikitext for Carrier siamese carrier... done
Getting wikitext for Carrier siamese snake... done
Getting wikitext for Carrier with feather... done
Getting wikitext for Cis-barge with tail... done
Getting wikitext for Cis-block and long hook... done
Getting wikitext for Cis-boat and dock... done
Getting wikitext for Cis-boat and table... done
Getting wikitext for Cis-boat with nine... done
Getting wikitext for Cis-boat with tail... done
Getting wikitext for Cis-fuse with two tails... done
Getting wikitext for Cis-hook and R-bee... done
Getting wikitext for Cis-hook with tail... done
Getting wikitext for Cis-loaf with tail... done
Getting wikitext for Cis-long boat with tail... done
Getting wikitext for Cis-mirrored R-bee... done
Getting wikitext for Cis-mirrored worm... done
Getting wikitext for Cis-mirrored worm siamese cis-mirrored worm... done
Getting wikitext for Cis-R-bee and R-loaf... done
Getting wikitext for Cis-rotated hook... done
Getting wikitext for Cis-rotated R-bee... done
Getting wikitext for Cis-shillelagh... done
Getting wikitext for Claw with tail... done
Getting wikitext for Claw with tub with tail... done
Getting wikitext for Cloverleaf interchange... done
Getting wikitext for Cthulhu... done
Getting wikitext for Dead spark coil... done
Getting wikitext for Dock siamese carrier... done
Getting wikitext for Eater 1... done
Getting wikitext for Eater 2... done
Getting wikitext for Eater 4... done
Getting wikitext for Eater head siamese carrier... done
Getting wikitext for Eater head siamese snake... done
Getting wikitext for Eater on boat... done
Getting wikitext for Eater siamese eater... done
Getting wikitext for Eater tail siamese carrier... done
Getting wikitext for Eater tail siamese snake... done
Getting wikitext for Eater with cape... done
Getting wikitext for Eleven loop... done
Getting wikitext for Elevener... done
Getting wikitext for Extra extra long snake... done
Getting wikitext for Extra long hook with tail... done
Getting wikitext for Extra long shillelagh... done
Getting wikitext for Extra long snake... done
Getting wikitext for Fourteener... done
Getting wikitext for Fuse with tail and long tail... done
Getting wikitext for Hat... done
Getting wikitext for Honeycomb... done
Getting wikitext for Hook with tail... done
Getting wikitext for House on house siamese table-on-table weld hat-siamese-hat... done
Getting wikitext for Hungry hat... done
Getting wikitext for Integral sign... done
Getting wikitext for Integral with hook... done
Getting wikitext for Integral with long hook... done
Getting wikitext for Integral with tub... done
Getting wikitext for Integral with tub and hook... done
Getting wikitext for Integral with two tubs... done
Getting wikitext for Lake 2... done
Getting wikitext for Loaf... done
Getting wikitext for Loaf siamese barge... done
Getting wikitext for Loaf siamese loaf... done
Getting wikitext for Long barge... done
Getting wikitext for Long boat... done
Getting wikitext for Long canoe... done
Getting wikitext for Long cis-hook with tail... done
Getting wikitext for Long cis-shillelagh... done
Getting wikitext for Long claw with tail... done
Getting wikitext for Long fuse with two tails... done
Getting wikitext for Long hook with tail... done
Getting wikitext for Long integral... done
Getting wikitext for Long long barge... done
Getting wikitext for Long long boat... done
Getting wikitext for Long long canoe... done
Getting wikitext for Long long hook with tail... done
Getting wikitext for Long long shillelagh... done
Getting wikitext for Long long ship... done
Getting wikitext for Long long snake... done
Getting wikitext for Long prodigal... done
Getting wikitext for Long shillelagh... done
Getting wikitext for Long ship... done
Getting wikitext for Long snake... done
Getting wikitext for Longhook and dock... done
Getting wikitext for Loop... done
Getting wikitext for Mango... done
Getting wikitext for Mickey Mouse... done
Getting wikitext for Mirrored dock... done
Getting wikitext for Moose antlers... done
Getting wikitext for Omnibus... done
Getting wikitext for Omnibus with tubs... done
Getting wikitext for Ortho-loaf and table... done
Getting wikitext for Paperclip... done
Getting wikitext for Pond... done
Getting wikitext for Pond and dock... done
Getting wikitext for Professor... done
Getting wikitext for Python siamese carrier... done
Getting wikitext for Python siamese snake... done
Getting wikitext for R-bee and snake... done
Getting wikitext for R-mango and house... done
Getting wikitext for Rotated C... done
Getting wikitext for Scorpion... done
Getting wikitext for Sesquihat... done
Getting wikitext for Shillelagh... done
Getting wikitext for Ship... done
Getting wikitext for Ship on long boat... done
Getting wikitext for Ship-tie... done
Getting wikitext for Sidewalk... done
Getting wikitext for Skew R-bees... done
Getting wikitext for Small lake... done
Getting wikitext for Snake... done
Getting wikitext for Snake bridge snake... done
Getting wikitext for Snake siamese snake... done
Getting wikitext for Snake with feather... done
Getting wikitext for Snorkel loop... done
Getting wikitext for Spiral... done
Getting wikitext for Super loaf... done
Getting wikitext for Super mango... done
Getting wikitext for Symmetric scorpion... done
Getting wikitext for Table and dock... done
Getting wikitext for Table on table... done
Getting wikitext for Tetraloaf I... done
Getting wikitext for Trans-barge with tail... done
Getting wikitext for Trans-block and long hook... done
Getting wikitext for Trans-boat and dock... done
Getting wikitext for Trans-boat and table... done
Getting wikitext for Trans-boat with nine... done
Getting wikitext for Trans-boat with tail... done
Getting wikitext for Trans-fuse with two tails... done
Getting wikitext for Trans-hook and R-bee... done
Getting wikitext for Trans-loaf with tail... done
Getting wikitext for Trans-long boat with tail... done
Getting wikitext for Trans-mirrored R-bee... done
Getting wikitext for Trans-R-bee and R-loaf... done
Getting wikitext for Trans-rotated R-bee... done
Getting wikitext for Tub... done
Getting wikitext for Tub with cis-tail... done
Getting wikitext for Tub with extra long tail... done
Getting wikitext for Tub with long long tail... done
Getting wikitext for Tub with long tail... done
Getting wikitext for Tub with tail... done
Getting wikitext for Twin hat... done
Getting wikitext for Up dove on dove... done
Getting wikitext for Up wing on wing... done
Getting wikitext for Very long integral... done
Getting wikitext for Very very long barge... done
Getting wikitext for Very very long boat... done
Getting wikitext for Very very long canoe... done
Getting wikitext for Very very long ship... done
Getting wikitext for Very^3 long boat... done
Getting wikitext for Very^4 long boat... done
Getting wikitext for Very^4 long snake... done
Getting wikitext for Very^5 long boat... done
Getting wikitext for Very^6 long boat... done
Getting wikitext for Very^7 long boat... done
Getting wikitext for Very^8 long boat... done
Getting wikitext for Very^9 long boat... done
Beehive and cap has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Beehive and dock has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Beehive at loaf has a 7 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Beehive with nine has a 6 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Bi-cap has a 9 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Bi-pond has a 4 glider synthesis on the wiki, but a 3 glider synthesis in Chris C.'s list.
Boat with long tail has a 5 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Boat with very long tail has a 8 glider synthesis on the wiki, but a 7 glider synthesis in Chris C.'s list.
Carrier siamese carrier has a 6 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Carrier siamese snake has a 6 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Carrier with feather has a 6 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Cis-R-bee and R-loaf has no synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Cis-block and long hook has a 5 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Cis-boat with nine has a 6 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Cis-fuse with two tails has a 8 glider synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Cis-hook and R-bee has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Cis-hook with tail has a 8 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Cis-long boat with tail has a 7 glider synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Cis-rotated R-bee has no synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Cis-rotated hook has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Dock siamese carrier has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Eater head siamese snake has a 8 glider synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Eater siamese eater has a 5 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Extra long snake has a 6 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Fuse with tail and long tail has a 7 glider synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Honeycomb has a 11 glider synthesis on the wiki, but a 9 glider synthesis in Chris C.'s list.
Integral with tub has a 5 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Loaf siamese barge has a 9 glider synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Loaf siamese loaf has a 8 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Long long hook with tail has a 7 glider synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Long long shillelagh has a 6 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Long long snake has a 5 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Long shillelagh has a 6 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Loop has a 5 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Ortho-loaf and table has a 6 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
R-bee and snake has a 7 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Sesquihat has a 6 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Ship on long boat has a 6 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Skew R-bees has no synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Snake bridge snake has a 9 glider synthesis on the wiki, but a 7 glider synthesis in Chris C.'s list.
Snake siamese snake has a 6 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Snorkel loop has a 6 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Super mango has a 25 glider synthesis on the wiki, but a 14 glider synthesis in Chris C.'s list.
Symmetric scorpion has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Table and dock has no synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Trans-R-bee and R-loaf has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Trans-block and long hook has a 5 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Trans-boat and dock has no synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Trans-boat and table has a 6 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Trans-hook and R-bee has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Trans-long boat with tail has a 5 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Trans-rotated R-bee has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Tub with cis-tail has a 8 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Tub with long long tail has a 7 glider synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Tub with long tail has a 5 glider synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Very long integral has a 9 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Very very long barge has no synthesis on the wiki, but a 4 glider synthesis in Chris C.'s list.
Very very long canoe has a 7 glider synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Very very long ship has no synthesis on the wiki, but a 5 glider synthesis in Chris C.'s list.
Very^3 long boat has no synthesis on the wiki, but a 6 glider synthesis in Chris C.'s list.
Very^4 long boat has no synthesis on the wiki, but a 7 glider synthesis in Chris C.'s list.
Finished at Mon Jan 9 18:47:51 2017.
6. Profit.