## Monday, 8 February 2010

### Farscape Intro Randomiser

While watching Farscape Season 2, Episode 4 (Crackers Don't Matter) last night, I wrote a Python script to randomise elements of the Farscape intro. Here's an example:

My name is John Crichton, a wormhole hit and I got shot through a military commander. Now I'm lost in some distant part of the universe on an insane radiation wave, full of escaped prisoners. I'm being hunted by a living ship. Doing everything I can. I'm just looking for a way home.

```import random

('insane', 'an'),
('living', 'a'),
('escaped', 'an'),
]

nouns = [
('ship', 'a'),
('military commander', 'a'),
('prisoner', 'a'),
('wormhole', 'a')
]

parts = []
parts.append(random.choice(nouns))
nouns.remove(parts[0])
parts.append(random.choice(nouns))
nouns.remove(parts[1])
parts.append(random.choice(nouns))
nouns.remove(parts[3])
parts.append(random.choice(nouns))
nouns.remove(parts[5])
parts.append(random.choice(nouns))
nouns.remove(parts[7])

result = 'My name is John Crichton, '
result += parts[0][1] + ' ' + parts[0][0]
result += " hit and I got shot through "
result += parts[1][1] + ' ' + parts[1][0]
result += ". Now I'm lost in some distant part of the universe on "
result += parts[2][1] + ' ' + parts[2][0] + ' '
result += parts[3][0]
result += ", full of "
result += parts[4][0] + ' ' + parts[5][0] + 's'
result += ". I'm being hunted by "
result += parts[6][1] + ' ' + parts[6][0] + ' ' + parts[7][0]
result += ". Doing everything I can. I'm just looking for a way home."

print result
```