I'm through with Pandorabots

After a brief fling with Pandorabots and AIML I have decided that the affair is over.

My reasons are that the AIML language is a little primitive and I can do better by coding a chat bot myself. Coding the engine and the chat bot itself seems much more exciting as a project to me.

Secondly, I can host as many chat bots as I want on my own domain (www.superdecadegames.com) for free.

One aspect of AIML that I can do better with is the <vrai> substitutions which require an awful lot of copying and pasting of pre-existing code and can cause problems when the thing you are substituting changes or does not exist.  The <that> construction makes code look a little messy overall and, as I am not afraid to get my hands dirty with some regular expressions, I should be able to produce something a little more impressive.

Well, work begins tonight.

Some of these should help.

Goodbye, Mac.  We hardly knew you!

I am slowly getting somewhere with my chatbot

So today I reworked most of my chatbot code so that he would accept multiple greetings ("Hi", "Hullo", "Hello" etc).  Also, I wanted Mac to respond with a friendly "what is your name?" and have the chatbot remember what to call you in the future.


This is achieved through the use of AIML <srai> recursion and setting context with <that>.

  • This code deals with matching multiple ways of saying 'Hi'.  What did I miss out?


<category><pattern>HI</pattern><template>Hullo. What is your name?</template></category>
<category><pattern>HI ^</pattern><template><srai>HI</srai></template></category>
<category><pattern>HELLO ^</pattern><template><srai>HI</srai></template></category>
<category><pattern>HULLO ^</pattern><template><srai>HI</srai></template></category>
<category><pattern>HEY ^</pattern><template><srai>HI</srai></template></category>
<category><pattern>HOWDY ^</pattern><template><srai>HI</srai></template></category>
<category><pattern>SUP ^</pattern><template><srai>HI</srai></template></category>

  • This code deals with the user replying to Mac's question "What is your name?"  Whatever is typed is stored in a variable called 'name' for later.

<category><pattern>*</pattern><that>^ WHAT IS YOUR NAME</that>
<template>It is nice to meet you <set name="name"><star/></set>.</template></category>
<category><pattern>MY NAME IS *</pattern><that>^ WHAT IS YOUR NAME</that>
<template>It is nice to meet you <set name="name"><star/></set>.</template></category>

  • This code deals with the user checking whether Mac has indeed remembered their name.
<category><pattern>WHAT IS MY NAME</pattern><template>You are <get name="name"/>.</template></category>
<category><pattern>WHO AM I</pattern><template><srai>WHAT IS MY NAME</srai></template></category>

Play chess in Facebook chat/messenger

I am loving this feature at the moment.  You can play chess with your Facebook buddies in a chat dialogue.

The chess feature is a hidden game that seemingly Facebook didn't announce but was instead discovered on a chess subreddit r/chess last December.



There is of course a chess app for Facebook by the excellent chess.com, which is acclaimed for being an excellent chess site, but this one might just get your buddies playing with you.

There is no point-and-click interface that you might be used to, instead you interact using commands.

Start a new game using @fbchess play.

Get help using @fbchess help.

Use chess notation to make a move. For example: @fbchess Pe4 moves your pawn to e4.

+1 Geek experience point to anyone who finishes a game.

I'm building a chat bot

Following my work on Susan, the ASCII personal assistant, I have become interested in chatbots. Today I set up an account with pandorabots and began to create my first bot - Mac, a ten year old cat from England.

It is early days yet.

It is still early days for Mac. Pandorabots use AIML (Artificial Intelligence Markup Language) for defining the responses to the human's input. I am still reading through the tutorial. There are libraries of responses you can import, however I want Mac to be unique, so I am coding him from scratch. As such, he can only respond to a few questions, but hopefully I will stay interested in the project and keep building him.

If you want to talk to Mac, then you will need a pandorabots account. There is an API through which I will eventually publish Mac, but for now I'll keep you posted on developments in this blog.

Mac, helping me code

I really like this Windows 10 feature

Recently some relatives made a long flight.  Naturally I wanted to track the progress of this flight (should be called 'mission').

At first I used flight radar. I found this very difficult to track an individual flight because although I knew the flight code (used by the airline operators), I didn't know the callsign code (used by air traffic control). I am not even sure whether I have got this distinction correct.

In some desperation I then typed the flight number into Cortana and was delighted to discover that she had it all covered.


Switching to my Lumia 950, the details were there in a nice Cortana card too.  Go Microsoft!

Next steps - Implement this feature in gorgeous ASCII for Susan.

Susan updated to 1.1.0.34

If you feel the need to be amused by an ASCII version of Cortana, then do click below to get Susan for your Windows PC.

I've updated Susan - the command line personal assistant app to the current version (1.1.0.34).

Susan - now with awesome ASCII loading screen.

What's new:
  • 'Susan' banner ascii art added on load screen.
  • Backwards compatibility added.
  • User defined variables now appear in the auto-suggestions.
  • Fixed bug where date appears as '01st of...'
  • Assignments can be made using variables.
  • Fixed bug where variables could not be the first term of an expression.
  • 'exec' function can take variables as a parameter eg exec <$myvar>
  • Fixed bug when displaying the '2nd' day of the month.
  • Goodbye message on closing.
  • 'tell me a joke' command added.
I've updated Susan - the command line personal assistant app to the current version (1.1.0.34).


Changing where Susan looks for the news

Unless you live in the UK, you will probably want to change where Susan looks for your news and weather information.  Susan uses RSS feeds to get news and weather.  By default these point to the BBC news feeds.  To change things, first find the RSS for the news or weather service you want.

Here is the RSS feed for BBC business news:

http://feeds.bbci.co.uk/news/business/rss.xml


To set the business news as your main news feed, type:

setNewsfeed http://feeds.bbci.co.uk/news/business/rss.xml


Type 'rerun' to check everything went as planned. You should now be getting the news from your chosen feed.

Changing the Weather Feed.

First find the RSS weather feed for your area.

Second use the setWeatherfeed command as described above for the news feed.  Type 'rerun' or 'weather' to check that everything is as expected.

Changing the primary feed.

The primary feed is an additional news feed that you can set to any RSS feed you like. Susan will pull items from this feed onto here display at random intervals whenever she is bored.

Set the primary feed using the setPrimaryfeed command, followed by the RSS feed, as described above for the news feeds.


Still reading?  
See all Susan related posts.  
You might also like - the Reverse Polish Notation Calculator.

Doing maths with Susan

Susan, the command line personal assistant, can perform calculations for you.  Simply type your expression followed by the all important equals sign (=).

For example:

3 + 4 =

Will output the answer '7'.


You can set variables using the equals sign as an assignment.

For example:

mass = 45.3

Then try:

force = 0.039

We can now use our variables in expressions:

force / mass =


Susan will keep your variables in memory so they will be available the next time you load her.

You might want to make expressions that are dependent on other variables.  For example, the acceleration is a function of mass and force.  Changing one of these will affect the acceleration.  To do this, use the 'relative assignment' operator (:=).

For example:


accel := force / mass


We can now make changes to both 'force' and 'mass' and use the updated 'accel' in other expressions:


3 * accel =

For a full list of built-in mathematical expressions, see the online help - simply type 'help' into Susan to load this up (or press F1).

Still with us?  
See all Susan related posts.  
You might also like - the Reverse Polish Notation Calculator.

I made a command line personal assistant in BASIC

I am not 100% serious about this application, however, just to amuse some students I have written a personal digital assistant app in BBC BASIC for Windows.

Introducing Susan - your command line personal assistant.

Susan running in Windows 10
Susan can:

  • compose email;
  • keep you up to date with the news and weather;
  • solve mathematical expressions;
  • remember your wife's birthday;
  • search The Web;
  • run macros and scripts;
  • keep time;
  • say stuff
For the full list of features see the online help, or Susan's homepage.

The current version (1.1.0.26) is available to download.  Should there be much interest in Susan, I'll add some new features (possibly alarms and reminders first).

I would appreciate helpful feedback through the social media links at the top right of this page. 

Robot arms with FUZE

I recently bought a couple of Raspberry Pi FUZE computers with Robot arm kit.

FUZE powered Raspberry Pi with Robot Arm kit available on Amazon right now.

Check it out on Amazon: FUZE powered by Raspberry Pi (RPi V2) - FUZE-T2-R Teach Kids to Code Unit English Keyboard with Printed Project Cards & Robot Arm Kit - Black/Red

Thanks very much to Nathan and Sam for assembling the two arms.

The FUZE computer is very similar in feel to the old BBC Microcomputer, but it is a Raspberry Pi under the hood.  It does all the usual Raspberry Pi things with the addition of FUZE BASIC pre-installed: a dialect of BASIC that allows you to program the robot arms.  The feel of the user guide is very similar to the old BBC Microcomputer user manual.

The robot arms have five motors that can be activated individually.  These motors control the rotation of the base, the shoulder joints, elbow, the wrist and the gripper.  You can program it to pick up objects and move them around.  One project I intend to do is to use one of my robots as an automatic air freshener.  Every few hours the gripper will squeeze a can of freshener into the room.

Code to control the robot arm

When you first get your robot set up you will want to start to control it.  The code that comes with the FUZE BASIC instruction book is rather limited.  I wanted finer control over the start and stop of the motors as well as the ability to control several of the machine's motors at once.

Presented here is my first attempt at some control code for the robot should it be of use to anyone.

You use the cursor keys to control the body and shoulder; Q/A/W/S for the wrist and elbow; Z/X for the gripper; ENTER to toggle the light, and SPACE for 'emergency stop' (you will need it!).  Type the program into the FUZE BASIC editor, or copy from this page and save it as 'robot.fuze'.  If in doubt contact me and I'll send you the file for your pi.

REM version 1.0.0.3
PROC resetArm
PROC displayInstructions


leftBodyOn = FALSE
rightBodyOn = FALSE
upShoulderOn = FALSE
downShoulderOn = FALSE
upElbowOn = FALSE
downElbowOn = FALSE
upWristOn = FALSE
downWristOn = FALSE
openGripperOn = FALSE
closeGripperOn = FALSE
lightOn = FALSE


CYCLE
key = INKEY
SWITCH (key)
REM right cursor - move body right
CASE 331
IF rightBodyOn THEN
armBody (0)
rightBodyOn = FALSE
    ELSE
armBody (1)
rightBodyOn = TRUE
ENDIF
ENDCASE

REM left cursor - move body left
CASE 330
IF leftBodyOn THEN
armBody (0)
leftBodyOn = FALSE
ELSE
armBody (-1)
leftBodyOn = TRUE
ENDIF
ENDCASE

REM space - reset
CASE 32
PROC resetArm
ENDCASE

REM up cursor - move shoulder up
CASE 332
IF upShoulderOn THEN
armShoulder (0)
upShoulderOn = FALSE
ELSE
armShoulder (1)
upShoulderOn = TRUE
ENDIF
ENDCASE

REM down cursor - move shoulder down
CASE 333
IF downShoulderOn THEN
armShoulder (0)
downShoulderOn = FALSE
ELSE
armShoulder (-1)
downShoulderOn = TRUE
ENDIF
 
ENDCASE

REM W - move elbow up
CASE 87, 119
IF upElbowOn THEN
armElbow (0)
      upElbowOn = FALSE
ELSE
      armElbow (1)
upElbowOn = TRUE
    ENDIF
ENDCASE

REM S - move elbow down
CASE 83, 115
IF downElbowOn THEN
armElbow (0)
      downElbowOn = FALSE
ELSE
armElbow (-1)
downElbowOn = TRUE
ENDIF
ENDCASE

REM Q - move wrist up
CASE 81, 113
IF upWristOn THEN
armWrist (0)
upWristOn = FALSE
ELSE
armWrist (1) 
upWristOn = TRUE 
ENDIF
ENDCASE

REM A - move wrist down
CASE 65, 97
IF downWristOn THEN 
armWrist (0)
downWristOn = FALSE
ELSE   
armWrist (-1) 
downWristOn = TRUE
ENDIF
ENDCASE

REM Z - close gripper
CASE 88, 120
IF closeGripperOn THEN   
armGripper (0)
closeGripperOn = FALSE
ELSE
armGripper (-1)
closeGripperOn = TRUE
ENDIF
ENDCASE

REM X - open Gripper
CASE 90, 122
IF openGripperOn THEN
armGripper (0)
openGripperOn = FALSE
ELSE
armGripper (1)
openGripperOn = TRUE
ENDIF
ENDCASE

REM ENTER - light on/off
CASE 13
IF lightOn THEN
armLight (0)
lightOn = FALSE
ELSE
armLight (1)
lightOn = TRUE
ENDIF
ENDCASE
ENDSWITCH

REPEAT

STOP


DEF PROC resetArm
armBody (0)
armShoulder (0)
armElbow (0)
armWrist (0)
armGripper (0)
armLight (0)
ENDPROC

DEF PROC displayInstructions
CLS
fontScale (2, 2)
INK = Red
PRINT "The Robots are revolting!"
INK = White
hvTab (0, 2)
INK = Green
PRINT "BODY and SHOULDER"
INK = White
PRINT "Cursor keys"
PRINT
INK = Green
PRINT "WRIST up/down"
INK = White
PRINT "Q/A"
PRINT
INK = Green
PRINT "ELBOW up/down"
INK = White
PRINT "W/S"
PRINT
INK = Green
PRINT "GRIPPER close/open"
INK = White
PRINT "Z/X"
PRINT
INK = Green
PRINT "LIGHT on/off"
INK = White
PRINT "ENTER"
PRINT
INK = Green
PRINT "EMERGENCY STOP"
INK = White
PRINT "SPACE"
PRINT
ENDPROC




I thoroughly recommend the FUZE or the robot arms (which will work with your current Raspberry Pi).  The robot will take about three hours to assemble and you will need a small screwdriver, a set of small pliers and a four 'D' batteries.

My Library

Are you sitting comfortably?  Good, then I will begin.

Once upon a time I used to loan books to friends.  Then I would forget all about it and spend hours searching for a book that was never returned (I am equally guilty at not returning books).

One solution is to take a photo of your friend holding the item and keep it on your phone so you don't forget.

I am, however, finding this app very useful at present.

My Library from smartcodeworks is surprisingly fun to use and makes managing your book library painless.  You simply scan the bar-code on the back of your book and the app retrieves the vital information and stores it in your phone.

Some of my books.

I recently moved house a couple of times, and today I got two cardboard boxes with about one hundred books between them out of storage. After evicting a spider, who had set up home in one of the boxes, I got to work scanning.  It didn't take long to scan all books into the app.

My Library app view on my awesome Lumia 950.

The My Library app has some solid features.


  • Scan by bar code.
  • Books or CD (but not DVD)
  • Manual entry.
  • Search title/author.
  • Live tile.
  • Back up to OneDrive.
  • Export to Excel spread sheet.
  • List by author/title/category.
  • Book reviews and price guide.
You can edit each entry, for example, the 'status' of the book can be set from 'purchased' to 'loaned' (so you can keep track of who has your books), 'wishlist' (you saw the book in a bookshop and plan to get it in the future, and 'borrowed' (it wasn't your book in the first place.

You can also write your own comment on each book.

The app copes well with bar-codes that don't belong to books. Here I am scanning a carton of semi-skimmed milk.



Stuff I would like to see


  • The ad-free version currently costs £2.29, but I won't be upgrading until there is a Windows 10 desktop app.
  • A search by author or title feature would be useful too. Currently it searches both.
  • Some different skins would be preferable as the main 'wood' themed one is rather dull. Just a plain dark theme would be good.
  • The ability to look up a book by ISBN on eBay. My dad wants this feature so he can keep track of the possible value of his rare books.  Last summer I wrote him a JavaScript app that does this, however it lacked the 'lookup by bar-code' feature of 'My Library' phone app.
It's worth how much?!

Old books without bar-codes need to be entered manually. :-(

Next steps for bibliophiles would be to look at other book sharing technology.  There is Google books which although I have never explored it fully allows you to share the information about books you have uploaded to your Android devices to be shared on G+. I have also stumbled upon Shelfari by Amazon (which may be less evil than Google), but that's another story for another day.


Bug squashed in data logger

Ooops!  I've just spotted a bug in my Raspberry Pi Sense HAT datalogging script.  The 'time' command causes the system to crash.  This is because you can't concatenate a date/time object to a string without first converting it to a string.  

The code should read:

    def do_time(self, args):
        """\n>Displays the current date/time"""
        self.mylog.setTime()
        print("\n>"+str(self.mylog.getTime()))

It is all fixed now.


Four weeks with #Microsoft Band 2

I have been wearing a Microsoft Band 2 for four weeks now.  This post is a tour of the features I have been using.

You can get a good deal on microsoft band at Amazon:
Microsoft Band 2 - Medium
Microsoft Band 2 - Large

The 'me' tile.
The 'me' tile shows the time at a glance like any good watch should.  You can also get the date, calories burned, steps taken, heart rate, flights of stairs climbed, steps taken and distance walked.

Swiping left brings up your tiles.  Maximum thirteen tiles can be pinned and three can be viewed at any one time.  Someone has just sent me a message - wooo! 
Tiles I have been using regularly in the order I have them pinned:


  • Messaging.  Lets me view the SMS arriving on my Lumia 950.  There is even an option to reply from this tile.
  • Facebook Messenger.  Lets me view my Messenger conversations.
  • Email. I get a lot of email. I can see from a glance if important messages are arriving without getting my phone out or logging into a computer.
  • Cortana.  This tile gives me regular messages from Cortana and lets me set reminders on the go by speaking into the microphone.
  • Calls. This lets me know who is ringing me with options to auto reply with SMS if I happen to be in a meeting or driving.
  • Calendar.  This is a digest of all my calendars and is very useful for seeing what is coming up next.  Notifications arrive for whatever reminders I may have set.
  • Sleep.  This tracks my sleeping patterns.  More about this later.
  • Alarms.  This tile lets me set alarms, reminders or run a stopwatch.  Useful for playing Cosmic Encounter.
  • Weather. A weekly forecast for my current location.
  • UV. Ultra violet light tracker.  Presumably useful for when I am sun bathing, but currently completely useless in the English winter.
  • Facebook.  See who is liking who.  Who's posting photos of their dinner.  Never miss a thing!
  • Twitter.  See who is following me.
  • Notes.  This is a third party app called 'Band companion'.  The notes app allows me to send notes from my Lumia 950 directly to my band.  It is the equivalent of writing notes on my hand with a biro, expect less messy.  This app also has features for remote camera shutter control and a battery indicator.
Stuff the band does but I don't use

I don't play golf.  I think that it is a massive waste of land.  In my opinion golf courses should be replaced with trees.  If we played cricket the same way we played golf we would play one over and then walk to another pitch to play the next one.  It just wouldn't be allowed.  Anyway, with that rant over, if I did play golf I would want my band 2 with me.  Not only does it know which golf course I am on using the GPS, it can also keep track of my score.

Most of my evenings are spent playing with computers, or other such geeky pastimes, but should I feel so inclined the band comes packed with apps for managing your workout, bike rides and runs.  It is not waterproof, so there is no functions for swimmers. 

The dashboard

As useful as the band is as a productivity tool, it really comes to life when you log into the Microsoft Health Dashboard.  Here you can track your steps taken or calories burned; organise workouts or compare yourself to other users.

Here was may last seven days in terms of how far I moved.  Verdict: could do better.



Here is my sleep record for the past several weeks. You can either tell the band that you are going to bed or the band will auto detect your sleep when it notices that you aren't moving very much and your resting heart rate has decreased.  I haven't had much sleep lately. Verdict: I'll catch up at the weekend.

The dashboard also gives you some useful comparisons with other people who are like you.  Here I can compare my resting heart rate and sleep efficiency with others in my age group.


Stuff the band 2 needs
I use Wunderlist a lot.  It would be useful if I could view my lists on my band.

Final verdict
Pretty awesome.  I love the health tracking element which is very useful even for someone like me who doesn't exercise much for fun.  The battery life could be improved.  I will get about 48 hours of constant use, but I'm lucky if my Lumia 950 will keep up with that.  There are some other features I didn't mention like the Bluetooth music controls which allows you to play and skip the music on your phone.  I don't have music on my phone - I keep it on my Raspberry Pi.

Plus one Geek Experience Point to Microsoft (who really don't need it) for the Band 2.

#microsoft #band2

Programming in the classroom using SHAPES

Thanks to Rachel Bush for producing some fabulous resources for using SHAPES in the classroom.

Rachel's resources are suitable for year 5-7 programmers (ages 9+)
SHAPES is a programming language for teaching kids the basics of computer programming and coordinates. They learn through creating pretty images using programming statements.

SHAPES is an easy introduction to computer programming.  It's tried and tested with kids and they love it.

Coded with SHAPES

Find all our SHAPES posts.
Open Rachel's SHAPES resources.
Open the SHAPES download page.

Label