What have you got to hide?

October 12, 2006 at 05:41 PM | categories: python, oldblog | View Comments

Some people wonder why I don't talk about my private life online, or 'silly things' like whereabouts I live in the world. The response  I generally give is "it's private". Some people however seem to think that in the modern age privacy is a bad idea, that if you want it you must have something to hide - as if privacy isn't a basic human right (Toilets have locks for a reason). Bruce Schneier's written an excellent article about privacy which sums up the debate as liberty vs control. I personally think that it really boils down to privacy matters and if its none of your business, it's none of your business no matter who you think you are, however aside from that final summing up I think its a great article.

It's also one of the reasons I'm interested in mechanisms to allow private communication to be integrated into Kamaelia, since the people engaged in private communications need to trust their not being evesdropped. This turns out to be a harder problem with Kamaelia than you might expect, mainly because of the high degree of decoupling in Kamaelia. (This is probably a good thing overall, since if you do manage to implement something you can trust you'll probably have a higher degree of trust in the system as a result. There's other practical applications at work (such as field journalists in hostile zones, or places with extreme censorship), but for me the basic need is one of privacy.

Read and Post Comments

RSS Sinks, RSS routers, Simplifying mashing up

October 06, 2006 at 05:35 PM | categories: python, oldblog | View Comments

There are many RSS sources on the web, and people are beginning to look at them as a form on unix pipe for the web. Whilst this isn't a bad analogy, it misses a number of things about pipes (especially graphline type pipe systems), which would make things more powerful. We've got a specific need here, so I'm thinking "what's the most Kamaelian way of doing this", and starting from the perspective of "what's missing". The rest of this post discusses the editted highlights of my thoughts.

What's wrong today with a web RSS feed as the universal pipe connector?
  • It's pull only
  • There's no apparent _standard_ way to push back - trackback is the closest I can find right now, but that's application specific, not a generic connector.
  • There's no mechanism for actually creating the pipe aspect as yet today
  • As well as pushing into the object you would then want to pull out the other sides (taking the Kamaelia viewpoint that you don't have just stdin/stdout)
  • The web is not the only source. Any device could easily publish one or many RSS feeds via zeroconf technologies, meaning you could fire up your machine, find out who's publishing a resource locally, and then play with the resulting feeds.
Ironically on the Kamaelia project we've now got a specific need where this would be of use, so I'm extremely tempted to deal with this. As usual the specific need is trivial - posting subversion checkins as news onto the website, but it would be extremely useful. The resulting tools would be reusable, which could be quite fun in a number of different places :)

Read and Post Comments

I got my old email address back!

October 03, 2006 at 01:32 AM | categories: python, oldblog | View Comments

An email address I had many moons back I now have again :-) You can now reach me once more at zathrus >A.T< mad >D.O.T< scientist >D.O.T< com :) (Note that's zathrus with a "u" not spelt correctly)
Sorry about the obfuscation, replace >A.T< with @ and >D.O.T< with a . (mutter nasty things about spammers)
Read and Post Comments

OO Prolog?

September 28, 2006 at 11:51 PM | categories: python, oldblog | View Comments

Looks like I haven't been paying attention to the prolog world. Since I last looked they've also gone all OO. Just heard about logtalk, which strikes me as interesting and perhaps coming back to. Description from freshmeat: Logtalk is an open source object-oriented extension to the Prolog programming language. Integrating logic programming with object-oriented and event-driven programming, it is compatible with most Prolog compilers. It supports both prototypes and classes. In addition, it supports component-based programming through category-based composition.

So not quite the prolog I originally learnt then ... :-) Or perhaps as prolog would say: no. Mind you, I've always thought that if prolog could be made useable by the average person that it would have some really interesting applications for users. After all, being declarative it does allow you to do a lot more by doing a lot less. You've got to wonder what the implications of a tutorial on event based systems in prolog where messages to objects are events have for other systems.
Read and Post Comments

Kamaelia 0.5.0, Axon 1.5.1, Article for LXF

September 24, 2006 at 11:25 AM | categories: python, oldblog | View Comments

Well, the release candidates for Kamaelia 0.5.0, Axon 1.5.1 have been created merged with the megabundle and uploaded to sourceforge, next comes the steps of finding what's broken (esp by last minute additions), and fixing. Meanwhile I've also written the Kamaelia article for Linux Format (december issue probably!), which is really cool. It focusses on the whiteboard largely, what you can do with it, and also has a section on how Kamaelia works from basic principles through to building graphlines.

I'm really quite pleased with it, and look forward to seeing what Linux Format do with it. (It's bound to be editted down and I imagine have its tone changed at least slightly!) It's made me realise that we missed out some dependencies from the MegaBundle, and that some areas need fixing, which is really useful.
Read and Post Comments

How not to give a talk at a Conference

September 20, 2006 at 04:31 PM | categories: python, oldblog | View Comments

I'm currently sitting in the session Scaling Up Open Collaboration and was expecting the two presenters to run a session, to run a talk. What have we got instead? We have a "video". This has instantly turned me off. Almost everyone in the room is now concentraing on their laptops, and not the message of their video. Despite the clear amount of effort and love that they've put in, they've failed completely to get their message across, which is a shame. If you run a talk, talk. I've been in bad talks, depressing talks, but all of these have been more compelling that smeone playing a video at me.

On a technical level, I watch a lot of TV - probably waaaay too much, and being in a broadcasting org I've picked up some tips about how to make a documentary, and this breaks a lot of rules. In places we have video, in others we don't. There doesn't appear to be a story being told... There's sections with people talking over text, which is fine, however the editors clearly recognised this alone isn't compelling, so they decided to add some background music. However if you're hearing isn't that great (like mine) then the fact that the music was louder than the person.

Another problem is the large changes in volume - the lack of good audo editting also turns me off.

Personally, I found the session awful. Ironically, if it'd been on youtube or google video, then there's a good chance I'd've watched it if linked through it.

As a session though, I found it painful.
Read and Post Comments

Daleks

August 21, 2006 at 08:57 PM | categories: python, oldblog | View Comments

Five million Scary Cybermen jumping through the void,
One fell badly, and whirled and whirled,
Rose phone The Doctor and The Doctor said,
"No more Cyberman taking over the world"

Four little Daleks, with a genesis pod
One got shot and bumped his head.
Rose phoned The Doctor and The Doctor said,
"No, no Daleks off you go to bed"


Read and Post Comments

Would you fly to the US right now?

August 12, 2006 at 12:42 AM | categories: python, oldblog | View Comments

That's the question on my mind right now. I'm supposed to go to the US for work reasons (Foo Camp) which is undoubtedly (almost?) a once in a lifetime opportunity, but does it outweigh the concerns I have over the fact that I'll have to check in my laptop into the hold ? (having had one data recovery experience this year, I don't want to risk a second) More importantly does it outweight the concerns my family have for my well being - that is they don't want me blown up ? That I really don't know right now. I do know that I'd planned on flying on one of the airlines that had apparently been targeted, which doesn't really inspire me.

The restrictions on what you can take on board for a long term flight (ie nothing) would probably also drive me barmy, and for EuroFoo and EuroOSCON I'm probably going to get the train - under 2.5 hours from Waterloo!

As you can probably tell, I'm rather undecided what to do right now. I've got about a week to consider though. Taking any longer and it wouldn't really be possible for Tim & co to re-allocate my space to someone else (something I'd like them to do if I can't make it to foo). Ironically, whilst my families biggest fear right now is of me being blown up, mine revolve around losing my data. I've already had that hell once this year and really could do without it a second time :-(

Any experience anyone else has had with laptops stowed in the hold would be encouraging to hear. (Even if my response is a little delayed...)
Read and Post Comments

The Long Tail Paradox - You don't need a tail

August 09, 2006 at 09:15 AM | categories: python, oldblog | View Comments

This is something I've been itching to write for a while, and I'm not sure I've got my analogies and descriptions right yet, but the gist is right more or less right (perhaps less than I'd like), the long tail sucks, viva le long tail...

The long tail - or rather Zipf's Law - has been getting a lot of publicity recently, which is nice in a way, but also suprising in others. I first came across the long tail 8 years ago when I started work at the Janet Web Cache Service in a variety of papers from the 3rd web caching workshop (which had been held in Manchester just before I started working there). The one thing that struck me was the fact that Zipf's law is a fundamental aspect of human behaviour (as fundamental as fire).

As a result, when people started putting catalogues on the internet people, whole new communities - business communities - started to see the effects of the long tail of human behaviour on their profits. Intuitively we all understand the long tail - we know that we want things that suit us, that match our desires.

However the reason why "hits" and "hit culture" took off is simple to explain - we all want quality. We don't want to choose from 20,000,000 things - this for me is the nightmare of the record store (online or real). Ask me what music I like and I'll say "good stuff". Don't ask me if it's garage or rap or indie, I don't know. I don't care about that subdivision, that label. I like cool stuff. I can point at stuff by Queen, stuff by Rob Dougan, Pictures at an Exhibition, the theme tune from twin peaks, Ernie the Milkman, Lilly the Pink, and so on. I don't classify my likes. As a result music stores suck for me (of almost all kinds).

Expanding that choice by even double, let alone 10 fold or 20 fold, leaves me cold. I'm aware that this makes it more likely that it is _possible_ for me to find something I'll like, but my ability to find it decreases as that choice size increases. This is Mooer's law in action. The usefulness of the system to me decreases as the amount of information increases.

I'm not alone. (I might be one datapoint, but I'm not arrogant enough to assume on a planet with 6 billion people to believe I'm that different from other people)

That's why top tens are good. It's why if I'm going on a long flight at an airport, I'm pleased that they have a top ten (or a variety of top tens). It's why I'm pleased that shops tend to operate on a principle of "survival of the fittest". If a book is good, it's likely to stay on the shelves (through restocking). If it's not, it's likely to disappear or get covered in dust. The smaller the shelf space, the more important those decisions become. Too much dust and you go out of business. Sure, the books available are less likely to be a good fit for me, but they're also more likely to be closer to the head than the tail (The tail being where the likelihood of it sucking for me increases).

This for me is the real issue. Why do you see zipf distributions? Because by and large the values as to what is good are shared by many people, we do tend to have similar likes on some levels to other people. That is why places like Amazon are particularly good, they don't just operate a long tail - every online bookstore does that - they allow people to gain insight into what's going on in that long tail. Similarly, Google News has the ability to look at what thousands of journalists worldwide have chosen to write about and chosen to publish. They then allow you to look at the head of that snake, by time, date, a search or a combination of all of these.

These services make the head & body of the long tail visible, which in essence is what we all want anyway, though personal to us.
The long tail exists because our tastes all subtley differ, and we all want quality. What you think is terrible, I might think is great. I still remember seeing Spawn at the cinema, how much fun I found it, and how good a film I find it, and yet, I'm still to find another person who agrees. The phrase "so bad it's good" is a cliche, and with good reason. If I say "The Matrix" however, you find lots of people agreeing that think its a cool film.

As a result, the head of the snake is useful. The head of the snake is a means of navigating yourself to content that lots of other people who may share similar tastes to you think is good for some reason. If you make the place to choose from attractive to a wide audience who choose from the wide variety of content, then the head of that snake will be attractive to that wide audience. And that's why hit culture took off. As long as everyone was choosing from the same pot and the reporting on that pot was accurate, then the top 10, top 40, top 100 was useful. That's why the top 40 in your local supermarket might be more relevant to you than a general top 40.

The real interesting aspect of things like recommendation engines is that they're personalising this snake. They're turning the snake into a hydra, and each head is a real user.

However, the interesting point is this: caching makes sense. Caching to be effective has to identify the head of the snake. By identifying the head of the snake, but still making available the tail the cache is useful, but provides a time benefit to the user and cost benefit to the provider with regard to the content. What does this mean in the context of a long tail? It means that small stores can exist, and can stock a wide variety of useful content, and can even use simple heuristics to make money. This is essentially what web caching does after all.

And why does caching make sense? It identifies the head & body of the snake, allowing you take advantage of the fact that the head and body have equal business or bandwidth value as the entirety of the tail, which is a choice set, many, many, many, many, times larger.

Now, I'm not a business person (by choice), but I'm savvy enough to realise this: if a web cache (fixed amount of choice of storage) can cope with the vagaries of an effectively infinite choice zipf distribution, and still turn a profit (ie be worth running), surely the same can be true of a business. You don't have to say "we'll stock everything", merely being able to get everything, and be able to serve the high quality stuff (as chosen by that audience) is sufficient. Furthermore, it's entirely likely that given a sufficiently "good" recommendation engine, that the amount you stock can be kept small.

The paradox of the long tail is this: you don't need a tail to take advantage of it, a virtual tail is sufficient - as long as you're willing to change your body and head to match the whims and desires of those choosing. If you can provide insight into that long tail, and shift content into a local store - and turn that tail into a body & head, then you increase the value of your proposition to the audience, and they will move your store along the long tail of online stores further towards the head, than the tail of online stores.

After all, if you could go into a store on the high street and say "give me something cool to listen to", and they did, and every time you went there not only did they give you something cool, but it got cheaper with time, surely you'd go back? You'd stop caring about the size of the tail, as long as you could get at it.


Read and Post Comments

Choose Your Own Programming Adventure!

August 07, 2006 at 12:45 AM | categories: python, oldblog | View Comments

I made the offer to write some exercises to teach python programming at OSCON, specifically in the form of being able to create a "choose your own adventure" style game using python. So, here we start! By the end of this first entry, you will be able to write a basic "choose your own adventure" computer game, even if you've never written a line of code before.

OK, there's dozens of ways of doing this, so we have to pick one. One place to start is to look at what the thing you're trying to emulate looks like.

What does a choose your own adventure look like?

Well, it's essentially a book, divided into lots of micro-chapters - at most 1.5 pages long, normally 1-3 paragraphs in length. Each paragraph has the following:

  • It is typically numbered and you start at section "1"
  • The section says where you are, tells a microstory, that ends with a choice point.
  • That choice point then allows you to move on to another part of the story

So, let's begin.

As a word of warning, this will start out gently, perhaps a little patronising, but hopefully with enough humour or bizarreness to offset that. The reason it might seem patronising is because I really want to point out some really important points, and without understanding those, everything else falters. However at the end of this first tutorial you will write your first adventure game, and don't worry, it will be simple.


The tutorial for sake of getting into the spirit of things, the tutorial is in the second person. This is YOUR adventure!

Prologue

You are sitting at the computer looking dumbly at the screen. You ponder your decision to decide to learn to code wryly, and realise that it might not've been such a bad idea after all. You decide to download python, and give it a go.

You go to http://www.python.org/download/ and grab a version suitable for your OS (unless you already have it installed because you have a recent Mac, or a modern Linux install) and install it.

The first program you are asked to run looks like this:

print "Hello, you are in a small dark room"

Unimpressed, but determined to follow the instructions, you open up a Terminal window, then load up the python interpreter:

~> python
Python 2.4.2 (#1, May 2 2006, 08:13:46)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

You type the code in, and press return, and are singularly unimpressed by the result:

>>> print "Hello, you are in a small dark room"
Hello, you are in a small dark room

That said, your lack of awe with regard to this fills you with hope. You realise that this programming lark might not be as difficult as some people make out.

The Lobby Scene Begins....

"AAARRRGGGHHH!", you think, "I'm late!" - as you remember that this is your first day at yet another job of the kind that you're hoping to use your hoped to gain programming skills to get out of. You're starting a new day as a receptionist at the local hotel, though thankfully only for postal & messages tasks. You remember the hassle you got last time when you were on the front desk and all those people from that open source conference were visiting - what a nightmare that'd been - everyone complaining about the wireless!

You arrive at work, some 10 minutes later, and after 20 minutes of waiting are thrown straight in.

In front of you is a large collection of old style pigeon holes on the wall. All 256 are numbered, though oddly starting from 0 all the way to 255. Puzzled by that you pass it by. Next to the collection of pigeon holes is a register which should contain a list of the surnames of the people staying in which rooms. You note that some rooms have multiple surnames associated with them. Since it's not the 1900's you're not particularly surprised by this!

You do for a moment wonder though - why's the story taken a turn for the moment towards hotels, pigeon holes, and surreptitious weekends away when the story should be related to teaching programming through adventures...

"WHAT ARE YOU DOING DAYDREAMING", shouts the concierge at you. "HAVE YOU FORGOTTEN WHY YOU'RE HERE?"

Suddenly you realise you have forgotten what you're doing. You decide to make a note on the notebook in front of you to remember what you're doing - you're taking messages and giving them back when requested.

Your First Assignment

A customer comes up.

"Ahh, your first assignment", says the concierge.

"Hi! I'd like to leave a message for Mr Message", says the customer.

You think this is a very odd name for a person, but reply "OK, sure, let me just check his room number". You consult the register and find that he's staying in room 5. You grab the slate board from pigeon hole 5, whilst thinking briefly how strange it is to be writing notes on slate boards, but hey, maybe the hotel management isn't really that bright, or just stick to simple things they trust.

"OK, ready, what's the message", you say.

"OK, the message is 'Hello, you are in a small dark room' ", the customer replies.

You pause for a moment thinking how strange this is - after all this was the message the tutorial you were reading suggested.

Undeterred, you say "sure, no problem", and write "Hello, you are in a small dark room" on the slate for the room that Mr Message is staying in, and store the message "Hello, you are in a small dark room" back in Mr Message's pigeon hole.

Strangely, the mysterious glyphs ...

>>> message = "Hello, you are in a small dark room"
>>>

... appear in mid air, burning like fire, but as cold as stone. There is a clarity about the phrase. It is trying to get you to understand something. Something about what you are doing in the hotel lobby storing a message, and what looks mysteriously like something you'd see on a python prompt.

You ponder for a moment what could possibly be similar between the code ...

message = "Hello, you are in a small dark room"

... and putting the text "Hello, you are in a small dark room", in a pigeon hole associated with a Mr Message?

A wry observer sitting the hallway nods sagely and realises that whilst such a description may be patronising, he's seen many a novice stumble over this initial step.

He walks forward and says: "Think like Daniel - the Karate Kid. How many times did he wax on, wax off, on those cars? When did he learn Karate? Was he merely polishing when he was hitting his opponents? or was he fighting those cars instead of polishing them? Sometimes realising that you already understand something is merely a matter of recognising that it is really no different from something you already know."

You pause. Pop reference. Telling you something you already know, but telling it to you in a way you hadn't expected. Australian accent. Hmm. Nah. You move on.

Then you realise - the old man was right. If taking a message for a man named "message" and placing it in a pigeon hole was an easy and obvious thing to do, something you'd seen a 100 times, then that was precisely what ...

message = "Hello, you are in a small dark room"

... means. It means taking a piece of information, storing it away somewhere, merely referenced by the name message.

Access All Areas

"PAY ATTENTION", shouts the concierge again. "DON'T YOU SEE THAT SOMEONE IS HERE?"

"Oh, sorry", you reply.

"Yes, I'd like to access my messages"

"Access my messages", you think, "how strangely these people in silicon valley speak. Maybe they've spent too long near their computers". However, you reply "Of course sir, name?"

"Message", he replies

For a moment you pause, you were about to ask "yes, but I need your name". However you realise that this is actually Mr Message - you remember that he does actually have a message.

You glance at the register, looking for the name "message", finding again that he's in room 5. "How could I forget that? That was like just a moment ago?". Shrugging, you grab the slate from pigeon hole 5 - and find "message" has the message (hmm, that's a bad turn of phrase you think) - that "message" has the value "Hello, you are in a small dark room".

You declare to Mr Message, "Your message reads, 'Hello, you are in a small dark room'".

As you do so, again those firey, cold, and compelling letters come into the fore again, but this time it's different:

>>> message
'Hello, you are in a small dark room'

Mr Message seems happy with this news, and wanders off. Presumably he just wanted to hear what was left in his box, and didn't actually want to do anything with it.

At this point in your thoughts you see the old australian again look up at you, give you a piecing look, and a smile that suggests that there is something here again. However all he says is, "Look at you figuring it out! You snake!".

Realisation - Revelations in a Lobby

More puzzled than before you wonder, what can he mean? Snake? What can be the relationship between a man coming up to you, saying "message", and you replying " 'Hello, you are in a small dark room' ", and the interaction on the python interpreter of:

>>> message
'Hello, you are in a small dark room'

You pause.

You think.

Then you smile.

The old man is trying to draw your attention to the fact that your role in the hotel lobby has been akin to that of the python interpreter. You have been the python - you have been the snake. Once you have been the snake there is no going back. From now on when ever you see the following on the python interpreter

>>> message = "Hello, you are in a small dark room"

You will think of the lobby. You will think of the pigeon holes, each with a slate that can hold only one message - only one value. You will remember the register on the desk beside the pigeon holes, and remember that it allows you to look up a pigeon hole from the name you're given. You'll remember that when you see:

>>> message = "Hello, you are in a small dark room"

That you will look up the room "message" is staying, grab the slate from the pigeon hole for "message", write the value "Hello, you are in a small dark room" on the slate, and then put the slate back.

Furthermore, you'll also remember that if someone merely requests the value associated with message, that is if you see:

>>> message

That they're not necessarily interested in doing anything with the value, they're just after the value.

You'll remember it's like someone coming up to the counter and saying "message" (or rather messages for Mr Message, but you filter out the boring parts), and that when they do that you look up which pigeon hole contains what they're after. You'll remember that you simply reply with the value in their pigeon hole.

Indeed, so patronising do you find the whole idea, you realise that the person behind the counter could be replaced with a little robot instead who merely sits there storing values for names, and when asked for values by name it replies with those values.

As a result, by this stage you think that the following is now painfully obvious to you:

>>> message = "Hello, you are in a small dark room"
>>> message
'Hello, you are in a small dark room'

You realise that "=" has nothing to do with mathematical equality (mind you, neither does gender equality!) as you learnt in school, and whilst there is a link, the reality is that what this...

>>> something_memorable = "some thing"

... really means is take the value "some thing", and store it in a location for safe keeping that we can come back to later and label that place "something_memorable". When asked for the value "something_memorable", by simply mentioing it's name:

>>> something_memorable

... we'll look at the location assocaited with "something_memorable", find the value "some thing" and merely return the value.

Your First Adventure

Excited, you realise that this actually is enough for you to get started with your first adventure!

OK, maybe it'll be a bit manual right now, and lets face it this will be a bit un-exciting as a first version, but hey, we need to learn to crawl before we can run right? And heck, we'll be able to translate all those old choose your own adventure books at this stage (but not those more fun Fighting Fantasy ones perhaps ! ;-).

You figure that surely the later steps in the tutorial will be about making this less manual, so you give the person writing this tutorial a break - after all this is about getting started as quickly as possible.

You do cut them a break, don't you? ;-)

So without further ado, we revisit what a choose your own adventure is - it's a collection of sections - all numbered - much like the rooms. Each section is a passage of prose, finishing with a little statement of where to go next.

Get a room!

You then figure. "Hmm. I can do that already. What would the first room look like. You excitedly open up your python interpretor and bash out your first section excitedly:

>>> one = "You are in a small dark room. You can see a dim light coming from the north and south exits. Type two to go south, and three to go north"

You sit back and think "It can't be that simple can it? There's all that choice stuff in those books?! They seem so complex? So rich? It can't be as simple as this". However your next step is to try it. What does it look like, can it really be this easy?

>>> one
'You are in a small dark room. You can see a dim light coming from the north and south exits. Type two to go south, and three to go north'

You sit back, stunned.

This is exactly what you wanted! (or said you wanted :-) OK you think, let's go north, I wonder what is north. You see that the instructions are "to go north, type three". So you do just that.

>>> three
Traceback (most recent call last):
File "
" line 1, in ?
NameError: name 'three' is not defined

Oddly however, you notice that your computer is also shouting this at the top of it's lungs in a voice that sounds remarkably similar to that of the concierge. At this point, you remember the hotel lobby. What if someone had come up to the desk earlier today and asked for messages for "Mr Three". There were no messages for "Mr Three", and furthermore, no "Mr Three" had ever checked in.

You realise that you're being unfair - the computer is a poor little dumb beast - it can't take a single value and create a whole adventure, it's just not that good. You need to provide it the adventure yourself. You take a heavy sigh, computers are dumb. They're very good at remembering things if you tell them things and something to remember them by, but you have to remember what you called those things.

Write your own Adventure

Expectantly, you sit back for a moment wondering what the author of this tutorial is thinking. Are they really expecting you to fill in the rest of the adventure yourself?

Suddenly, as if by magic some hints fall from the sky in the form of more activity on the python prompt:

>>> two = "You have entered a clearing. It is a warm and sunny clearing, and you hear birds chirriping, and children playing in the south. You smell the strong familiar scent of coffee to the east. To go east, type four. To go south type five. To return north, type one"

>>> three = "You are in a maze of twisty passages all alike. You continue on for a while and the passageway branches to the right. To continue straight on type three. To turn right type six. To turn back, type one"

Now seeing what the idea is, you copy the text out, into a text editor, and format it over 3 lines to look like this:

one = "You are in a small dark room. You can see a dim light coming from the north and south exits. Type two to go south, and three to go north"

two = "You have entered a clearing. It is a warm and sunny clearing, and you hear birds chirriping, and children playing in the south. You smell the strong familiar scent of coffee to the east. To go east, type four. To go south type five. To return north, type one"

three = "You are in a maze of twisty passages all alike. You continue on for a while and the passageway branches to the right. To continue straight on type three. To turn right type six. To turn back, type one"

Excitedly you copy and paste these three lines into an open python terminal. You decide to start your adventure, head south, then north, enter the tunnels, and return back the way you came:

>>> one
'You are in a small dark room. You can see a dim light coming from the north and south exits. Type two to go south, and three to go north'
>>> two
'You have entered a clearing. It is a warm and sunny clearing, and you hear birds chirriping, and children playing in the south. You smell the strong familiar scent of coffee to the east. To go east, type four. To go south type five. To return north, type one'
>>> one
'You are in a small dark room. You can see a dim light coming from the north and south exits. Type two to go south, and three to go north'
>>> three
'You are in a maze of twisty passages all alike. You continue on for a while and the passageway branches to the right. To continue straight on type three. To turn right type six. To turn back, type one'
>>> three
'You are in a maze of twisty passages all alike. You continue on for a while and the passageway branches to the right. To continue straight on type three. To turn right type six. To turn back, type one'
>>> three
'You are in a maze of twisty passages all alike. You continue on for a while and the passageway branches to the right. To continue straight on type three. To turn right type six. To turn back, type one'
>>> one
'You are in a small dark room. You can see a dim light coming from the north and south exits. Type two to go south, and three to go north'

Happily you sit back, you realise that now it could be just a matter of translating a story into a number of assignment statements, entering those into the interpreter, sitting back and enjoying the results.

Get Some Exercise

Suddenly a storm cloud comes over the horizon, and you sit, worried. How can I avert this, and you realise there is only one way - you have to get some exercise - you have to write your first version of the adventure. Yes its trivial right now, and actually writing the adventure might actually be the harder part here, and you notice that your existing code is decaying and dying. The principles of that code remain in your mind - associate a section with a name starting with one. In the prose of the section associated with that name state "To do X type <sectionname>", and for all the section names include some text.

Some suggestions spring to the screen.

  • Imagine you are writing a choose your own adventure computer game set around discovering the body, entering at the mouth. Some example possible sections:
    • one - "You are in the mouth. Would you like to look around (type two), go down the throat (type three), or open a vein and dive in (type four) ?"
    • two - "You don't see anything particularly interesting and decide to: go down the throat (type three) or open a vein and dive in (type four)."
    • etc
  • Imagine you have a time machine that can materialise and dematerialise at any point (or points) in time and space. You start off in your local city and time (one), and from there on have the choice of traveling through time (two), space (three) or both (four).

This is clearly the first exercise, and is actually a fair amount of work, though largely creative. It's worth noting here that being silly is probably a good idea, since it'll a) be more fun b) probably create a larger volume of text and sections to be working with. Certainly this tutorial is longer than I anticipated due to the slightly whimsical tone :-) I'd suggest at least ten sections, but no more than 20. When you're done, it'd be really cool to see different answers posted as replies to this blog entry. I'll hold back moderating replies with answers as public for about a week, and then make them public.


In case no one actually posts any answers, I'll post a set of answers as well!
Read and Post Comments

« Previous Page -- Next Page »