Monday 28 December 2009

Why am I doing this to myself?

So, I've been having trouble sleeping lately and have been staying up to ridiculous hours in the morning.  No real change from normal, but usually it's a case of choosing to stay up, rather than just staying up.  Now during this excess time, I've managed to productively do a lot of unproductive stuff (hurray for nearing 100% completion on Fallout 3), and I have no intention of moving away from this.  With this in mind, I present to you my entertainment for tonight:

The 1st "Abandon All Hope" Uwe Boll Film Marathon!

7 films totalling nearly 12 hours of "entertainment"
including such Boll KG classics as:

Alone in the Dark
BloodRayne
Far Cry
House of the Dead
House of the Dead 2
In The Name Of The King - A Dungeon Siege Tale
Postal

Starting tonight at roughly 11:30 pm, I will subject myself to these films,
one after another.  During which time, I will only stop if my brain starts to
dribble out of my nose (a very real possibility).

During this period, I'm going to regularly tweet as I start each film, and give my
feelings as I reach the end, a more in depth analysis will be put up here shortly.

Wish me luck

Friday 18 December 2009

Snow!

Excuse me while I engage in some childish glee and ill-advised frolicking!  
Yay, Snow!




Snow!

 


Lots of Snow!

Whoo Snow!

Snow angels!

And now for the cynical part, a camera that generally sucks at taking photos at night.


Ok, that wasn't too bad, but this one sucks:

I mean seriously even I don't know what that's a photograph of and I took it.

Wednesday 21 October 2009

So hilariously accurate

Today's xkcd really made me smile, if only because it's so very very true


Tuesday 20 October 2009

Updated word-search solver in perl

 I've been busy, updating my word search solver that I wrote about a month ago now, and have managed to make several improvements.  Once again I've uploaded the code to perlmonks, but this time I've also posted it here (finally figured out that block quote will work nicely in laying out code).  In essence the code remains the same, with just a few added features, including:
  • The puzzle is now loaded from a text file (an example is given below).
  • The program now accepts command line arguments to give help, version information and to select the file to use.
  • A slightly greater list of internal commands, for a full list type #help at the programs prompt.
An example of a Puzzle file:
In order to actually use the program now, you have to supply it with a file containing the puzzle to be searched.  This is simple to set out, each letter of the puzzle is put in the file with a single space between columns and a new line between rows (see the example below):
r e l a e d b y
e s c r e e n t 
m i o e i s h l 
i s l a t e r a 
t n u r c n n u 
r g m u a i h s 
o u b m t h a a 
m e o a n c c c
The program expects you to supply a file from the command line (using the -f switch) when you start, but will prompt you for one if you forget it.

The Program itself:
#!/usr/bin/perl
# wordSearchSolve.pl
# Program to solve a word search puzzle semi-automatically.
#
# With thanks to toolic, Limbic~Region and Count Zero of perlmonks.org for 
# suggesting several improvements.
#
# Christopher Dykes (2009-10-19) - (v2.2)

#Enable the following packages:
use strict;  #Enable strict syntax checking
use warnings;  #Enable diagnostic warnings
use Getopt::Long; #Enable command line option parsing

#Define constants:
use constant 'VERSION' => 2.2;

#Declare local variables:
my($i, $j, $k, $word, $found); #Various control variables
my $done = 0;   #Whether we're finished or not
my(@start, @end);  #The start and end locations of the word
my @puzzle;   #The puzzle to be searched

#Parse command line options:
my($file, $help, $version); #Available command line options
GetOptions('file=s' => \$file, 'help' => \$help, 'version' => \$version);

&help    if($help); #Display the help message
&version   if($version); #Display the version details
@puzzle = @{&puzzleGet($file)} if($file); #Open our file if we have one

exit if($help || $version);

if(!$file) #Get a file from the user if they haven't supplied one
{
 my $check = " ";
 while($check ne "y")
 {
  print "WARNING: No File supplied, supply now? (y/n) ";
  $check = lc();
  chomp $check;
  
  exit if($check eq "n");
 }
 print "Enter file name:\t"; $file = ;
 @puzzle = @{&puzzleGet($file)};
}

#Display the header:
print "Wordsearch Solver (v", VERSION, "):\n\n";
print "Enter the term to search for, enter '#quit' to exit ";
print "and #help for assistance\n\n";

#Allow the user to search:
while(!$done)
{
 print "> "; chomp($word = ); #Get the word from the user
 my @chars = split(//,  $word);
 my @words = split(/ /, $word);

 if($chars[0] eq "#")
 {
  $done++  if($word eq "#quit");
  &internalHelp if($word eq "#help");
  if($words[0] eq "#newpuzzle")
  {
   @puzzle = @{&getPuzzle($words[1])};
  }
 }
 else
 {
  print $word, "\t= ";
  my @word = split(//, $word);

  for($i = 0, $found = 0; $i < @puzzle && !$found; $i++) #Row loop
  {
   for($j = 0; $j < @puzzle && !$found; $j++) #Col loop
   {
    for($k = 0; $k < 8 && !$found; $k++) #Dir loop
    {
     my @gen = ("");
     $found = &search($k, $i, $j, \@puzzle, \@word, @gen);
    }
   }
  }
  print "($i,$j) - ($end[0],$end[1])\n" if($found);
  print "NO RESULT\n" if(!$found);
 }
}

#Subroutines begin here:
sub search #Performs a recursive search across the puzzle
{
 #Declare local variables:
 my($dir, $row, $col, $puzRef, $wrdRef, @gen) = @_;
 my @puzzle = @{$puzRef};
 my @word   = @{$wrdRef};

 ($end[0], $end[1]) = (($row + 1), ($col + 1)); #Set our end location

 return 0 if($puzzle[$row][$col] ne $word[$#gen]);
 return 1 if($#word == $#gen);

 #Decide what to do:
 $row++ if(($dir == 0 || $dir == 4 || $dir == 5) && $row < $#puzzle);
 $row-- if(($dir == 1 || $dir == 6 || $dir == 7) && $row > 0);
 $col++ if(($dir == 3 || $dir == 5 || $dir == 7) && $col < $#puzzle);
 $col-- if(($dir == 2 || $dir == 4 || $dir == 6) && $col > 0);
 
 #Do the useful stuff:
 push(@gen, $puzzle[$row][$col]);
 return 1 if(&search($dir, $row, $col, \@puzzle, \@word, @gen)) || return 0;
}
sub puzzleGet
{
 my @puzzle;

 open(FILEIN, "$_[0]") || die("Couldn't open file $_[0]");

 while()
 {
  chomp($_);
  my @line = split(/ /, $_);
  push(@puzzle, \@line);
 }

 return \@puzzle;
}
sub help
{
 print "Usage: wordSearchSolve.pl [OPTION] -f [FILENAME]\n";
 print "A program to solve a word search automatically\n\n";
 print "-f\t--file\t\tLoad the puzzle from this file\n";
 print "-h\t--help\t\tDisplay this message\n";
 print "-v\t--version\tDisplay version information\n\n";
 print "Report bugs to .\n";
}
sub version
{
 print "wordSearchSolve (v", VERSION, ")\n";
 print "Copyright (C) 2009 Christopher Dykes.\n";
 print "License GPLv3+: GNU GPL Version 3 or later \n";
 print "This is free software: you are free to change and redistribute it.\n";
 print "There is NO WARRANTY, to the extent permitted by law.\n\n";
 print "Written by Christopher Dykes.\n";
 print "With thanks to toolic, Limbic~Region and Count Zero of perlmonks.org\n";
 print "for suggesting several improvements.\n";
}
sub internalHelp
{
 print "\nAvailable commands are:\n";
 print "\t#help\t\tDisplay this message\n";
 print "\t#newpuzzle\tLoad a new puzzle from a file\n";
 print "\t#quit\t\tExit the program\n";
 print "\n";
}
download here

Friday 25 September 2009

Doing some AI stuff in Perl

So, I've written a semi-automated Word Search Solver in perl over the last couple of days, I haven't uploaded the code to here, because I haven't found an adequate way of formatting the code yet (I sense another project coming up), but the post link should send you to the page on perlmonks where I uploaded to the post too, all of the details are there, but for completeness sake and to tantalize you into going there, I'm going to post the details here:

Description:
The code below is for a semi-automatic word search solver, that uses a recursive function to search a multi-dimension array containing the puzzle for the word that the user asks for.

The program is semi-autonomous, in that the search itself is carried out automatically, but the puzzle is (for the moment) hard-coded, and the user must enter each word that they want to search for one-by-one.

Interface:The interface is a simplistic text-based one, the user enters the word that they want to search for, and the program responds with a set of coordinates for the start and end positions of the word being searched for, or 'NO RESULT' if the word can't be found.
The only command available to the user apart from the search ability is the '#quit' command which exits the program.

Considerations: The program relies on the assumption that the dimensions of the grid to be searched are equivalent, i.e. rows == cols

Planned Improvements:
  1. The option for the user to enter in the puzzle data 'on the fly'
  2. Removal of the final global variable '@end'
  3. The ability for the user to define a list of values to search for
If that doesn't peak your interest then this probably isn't the sort of thing for you, but if you're interested in AI search techniques, solving word searches, variable references, or how to do any of the previous in perl, check it out.

Thursday 27 August 2009

age++

Today is my 21st birthday, a year I'm told by everyone is important but (and you know it's bad when I'm quoting the 1994 Street Fighter movie, and even then altering the quote slightly to be more accurate) "for me it was Thursday".  Maybe I'm just cynical but, on examination, I can tie no major significance in my life to this number, during the build up I decided to generate a list of the things that I am now able to do that I couldn't do before; that list is woefully short, constituting the fact that:
  1. I can now legally purchase alcohol in the United States, this is tempered by the knowledge that I don't live in the US and have no plans to visit in the immediate future,
  2. I can legally hire a car, redundant in that I already own one, and I'm not planning to travel anywhere that would require me to rent one.

Perhaps this is all a result of the fact that I couldn't sleep last night and became introspective, always a dangerous thing for me to do, but looking back I found more remembered significance in my eighteenth birthday, back then I felt that I had been given access to all the tools I needed to make my mark on the world; I could vote, I didn't have to keep a complicated list of which pubs Id'd and which didn't.  Even the earliest birthdays seem to be more important, despite the fact that all the major details of them have been smoothed from my mind, and I only have this sense of being little and protected and unique.

Maybe this really is what the significance of being 21, the knowledge that this really is it, maybe it's that I haven't had enough cake yet. Oh, and suggest that I wear a badge with "Hello I'm $age" today, and I will take great delight in flaying your mind with sarcasm.

Sunday 19 July 2009

London Film and Comic Con 2009

I attended the London Film and Comic Con yesterday, and finally achieved one of my ambitions; namely meeting the lovely Jewel Staite:

Now without sounding like a gushing fanboy (I can already here the voice at the back of my head saying that I already do), she is such a nice person. I mean, I know she's an actress, and she was getting paid to do this but she really seemed interested in the people who were talking to her, and even remembered me when I saw her again later in the day.

Overall, I thought that the con went really well, there was a general feeling of enjoyment, throughout the day from the little kid excited because Darth Vader was wandering around, to the guy in the Xenomorph suit (who seemed to enjoy chasing after attractive women a bit too much to be considered "just doing his job").

Although I only got to meet Jewel, the other stars there also seemed to be enjoying the atmosphere. Notable examples were Hattie Hayridge looking up and smiling as I photographed her, and Tom Baker enjoying a bag of Jelly babies while signing autographs.

The layout of Earl's Court itself also tends to provide a good structure for a con, allowing lots of space for people to move around.

So that really sums up my trip, for me, the real high point was the following image:

although nearly-naked-cave-girl came a close second.

Thursday 11 June 2009

Terminator Salvation: The perspective from an AI guy

Films with AI in them have always fascinated me, I'm doing an Artificial Intelligence based degree, so it's always fun to go and see whether they get anything right.

Terminator Salvation was thus a natural choice to go and see, because not only does it have an AI, we also get killer robots which, despite the fact that their Asimovian counterparts make for deeper story lines, gain massive bonuses because of the inevitable "who would build something like that?" questions which typically end with me pointing a finger at myself and smiling.

Now I'm a hard man to please when it comes to films, I grew up on a steady diet of sarcasm and Mystery Science Theatre so I tend to be mocking towards most films that I go and watch. In particular I tend to be most mocking towards actors who hype themselves up dramatically, yes I'm looking at you Christian "I'm BATMAN" Bale. This was a real issue for me in going to watch the film, because I like the Terminator franchise (with the exception of Terminator 3), and I wasn't sure if I was going to enjoy Salvation because we see Christian Bale getting beaten up repeatedly or be throwing Popcorn at the screen as I had to sit through Batman versus Terminator.

Overall though the film didn't disappoint, yes we had Bale's deeply macho voice grating out at us like a blender filled with gravel. But that was the only real downside to an otherwise pretty good film. Things that really stood out for me where:
  • The attempt at making the intro credits look like part of a program, which led to Verena and I simultaneously trying to debug the credits,
  • The weird fact that the resistance seems to get all of its computer hardware from the same place I do (the Sony Vaio tablet, the cruzer flash drives) meaning that expansys still exists in the Post Judgement day world, or that John Connor looted my corpse,
  • The fact that I can sit there and think "I could build a better kill bot than that" forgetting temporarily the plot-shields surrounding certain cast members,
  • The new Mr Chekov being Kyle Reese "Keptin I've spotted Skynet Wessels!"
  • And finally there was the really commendable work done by the CG department to hide Arnie's balls; a hand, a shadow, some smoke they used it all.
In conclusion, if you're like me (and even if you're not) go and see it, at the very least you'll be amused for a couple of hours.

Tuesday 9 June 2009

Plans for the now

So, with summer truly upon us, I've decided that it's going to be good weather to actually go and fly a couple of model rockets. With this in mind, and in order to procrastinate about my exams that start tomorrow I've dug out my copy of The Handbook of Model Rocketry in order to convert the programs contained in there over to perl, so that I can run some simulations on a couple of designs I want to build.