Showing posts with label AI. Show all posts
Showing posts with label AI. Show all posts

Wednesday, 9 June 2010

Bloody hell, I started this thing a year ago!

Wow, what a wild series of accomplishments I've made on here in that time. I think it's exactly the right time to reflect on the many wonderful and splendid things I've done here such as...uh...um...well there's...Here have some George Takei being awesome to distract you while I think of something!





In all seriousness though, I will admit, I haven't posted very much on here, this will be my 31 post to this blog, implying a post rate of 0.59 posts per week. Now as to why this is, there are a number of reasons I could drag out in order to explain this, but ultimately, they're all going to be excuses when the real reason would ultimately be laziness. With the ending of the exams shortly though, I intend to become more active with my posting (whilst still intending to keep the same level of quality content). Possible posts forthcoming include
  • More "I'm Batman!" and "Holy Shit Christopher Walken!"
  • A planned trip to London Film and Comic Con 2010 (Shatner is a guest)
  • My thoughts on the portrayal of Artificial Intelligence in films over the years

Monday, 11 January 2010

All kinds of creepy

Okay, I'm gonna establish a few things before I get onto the meat of this post
  1. I do not consider myself a prude, despite using terms like "Man Reaction" (purely because it's funny), or think of myself as one to get freaked out by peoples lifestyle choices.
  2. Although some people wouldn't think so, studying Artificial Intelligence means that you get to look at certain very strange concepts, and the idea of a sexbot is nothing new to me, in fact I've listened to several talks on whether this would be a good idea in the past.
  3. Without sounding like I'm a sociopath in a sweater-vest the sheer complexity of correctly programming a machine to perform this task is tantalising, and certainly something I've pondered doing as a future career (usually after watching too many episodes of Dollhouse).
 That established, I read an article on the Telegraph today, which, while certain parts are interesting, other parts just contain high-octane nightmare fuel.  The story is about a robotic sex toy that can "communicate" with it's owner.  Now, this in and of itself is not the scary part, that gets reserved for the following lines:
"a young unnamed doll with a naïve personality"
 I mean wow, just wow can any one say paedophilia starter set. That's the kind of thing that Chris Hansen would want to have a talk with you about. The second is this immortal line:

"Inspiration for the sex robot sprang from the September 11, 2001 attacks, he said, where a friend died and he vowed to store his personality forever."
Yeah, that's just wrong. I mean, why would you do that? I mean I understand, he lost a friend under tragic circumstances, but what would have to go through your mind to generate that chain of logic, I mean it just seems to end up like this in my brain:
 Given:
    The Death of my friend,
    and that I didn't want my friend to die
Then:
    I will design a system to store my friends personality forever.
Therefore:
    A high-tech sex toy is probably the best thing to get to work on.
IT JUST DOESN'T MAKE SENSE!


I don't believe in an afterlife but, if I'm wrong, I'm fairly certain the inventors friend is desperately trying to find some way back from the dead to kick the ever loving crap out of the guy. I mean is that what you would want as your legacy? "I died so that someone can get some virtual nooky!".

I mean, okay I haven't lost a close friend in a terrorist attack, but even I know that if you're going to improve a scientific field so that others don't have to go through your loss, you work on something like cryogenics, or the ability to download a human brain into a computer, or advanced cloning, not a sex doll!


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, 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.