The three rules of Ruby Q.:
-
Please do not post any solutions or spoiler discussion for this quiz
until
48 hours have passed from the time on this message. -
Support Ruby Q. by submitting ideas as often as you can:
- Enjoy!
Suggestion: A [QUIZ] in the subject of emails about the problem helps
everyone
on Ruby T. follow the discussion. Please reply to the original quiz
message,
if you can.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
by Morton G.
[ Editor’s Note:
I realize we’ve done a similar quiz in the past, but read on and give
this one a
chance. It has a pretty different spin than Markov Chains.
–JEG2 ]
The Dwemthy’s Array RPG example in Why’s (Poignant) Guide to Ruby[1] was
my
introduction to Ruby metaprogramming. While it’s an excellent
introduction to
metaprogramming, it’s not much of an RPG, so I thought I’d have a go at
improving it. But a funny thing happened when I started coding: the RPG
turned
in a story generator. Here are a couple of stories generated by my
current
version.
The first story is fairly typical of the shorter ones. The rabbit gets
past the
BogusFox only to fall to the Jabberwocky.
A BogusFox emerges from the gloom and cries out,"Hail, Rabbit,
prepare to die!"
"I fear you not, BogusFox!"
Rabbit [25] and BogusFox [50] fight.
Rabbit attacks BogusFox with magick sword.
Fighting lowers BogusFox life force by 9.
BogusFox suffered a minor wound.
BogusFox swings his axe.
Fighting lowers Rabbit life force by 7.
Rabbit was wounded.
Rabbit [18] and BogusFox [41] fight.
Rabbit attacks BogusFox with magick sword.
Fighting lowers BogusFox life force by 43.
BogusFox dies.
Eating magick lettuce adds 7 to Rabbit life force.
A Jabberwocky emerges from the gloom and cries out,"Ah, a tasty
Rabbit!"
“I fear you not, Jabberwocky!”
Rabbit [25] and Jabberwocky [100] fight.
Rabbit attacks Jabberwocky with magick sword.
Fighting lowers Jabberwocky life force by 63.
Jabberwocky was seriously wounded but carries on.
Jabberwocky attacks Rabbit with teeth and claws.
Fighting lowers Rabbit life force by 33.
Rabbit dies.
It’s over. It’s all over.
The second story is an example proving that low probability events do
occur. The
rabbit actually wins! And what’s truly amazing is that he kills every
monster
with a single stroke of his magick sword. Talk about luck!
A BogusFox emerges from the gloom and cries out,"Hail, Rabbit,
prepare to die!"
"I fear you not, BogusFox!"
Rabbit [25] and BogusFox [50] fight.
Rabbit attacks BogusFox with magick sword.
Fighting lowers BogusFox life force by 59.
BogusFox dies.
Eating magick lettuce adds 37 to Rabbit life force.
A Jabberwocky emerges from the gloom and cries out,"Ah, a tasty
Rabbit!"
“I fear you not, Jabberwocky!”
Rabbit [62] and Jabberwocky [100] fight.
Rabbit attacks Jabberwocky with magick sword.
Fighting lowers Jabberwocky life force by 155.
Jabberwocky dies.
Eating magick lettuce adds 46 to Rabbit life force.
A DemonAngel emerges from the gloom and cries out,“Rabbit, I will
eat your soul!”
“I fear you not, DemonAngel!”
Rabbit [108] and DemonAngel [540] fight.
Rabbit attacks DemonAngel with magick sword.
Fighting lowers DemonAngel life force by 600.
DemonAngel dies.
Eating magick lettuce adds 20 to Rabbit life force.
A ViciousGreenFungus emerges from the gloom and cries out,“No Rabbit
has ever left my presence alive.”
“I fear you not, ViciousGreenFungus!”
Rabbit [128] and ViciousGreenFungus [320] fight.
Rabbit attacks ViciousGreenFungus with magick sword.
Fighting lowers ViciousGreenFungus life force by 390.
ViciousGreenFungus dies.
Eating magick lettuce adds 35 to Rabbit life force.
A Dragon emerges from the gloom and cries out,“A brave Rabbit burns
just as well as a timid one.”
“I fear you not, Dragon!”
Rabbit [163] and Dragon [1340] fight.
Rabbit attacks Dragon with magick sword.
Fighting lowers Dragon life force by 1436.
Dragon dies.
Eating magick lettuce adds 44 to Rabbit life force.
It’s over. It’s all over.
The secret of the rabbit’s magick sword will be revealed when my story
generated
is posted.
“It’s hardly literature,” you say. I agree. “It’s needs more work,” you
say.
Again, I agree. But it does tell a story. Don’t you root for the rabbit?
Don’t
you feel just a little sad when he’s killed (as he almost always is)?
And isn’t
it wonderful when, once in a hundred runs or so, he actually kills the
dragon
and completes his quest?
Story generators can be a lot of fun. Even addictive. It’s fascinating
to create
your own world. And they are completely open-ended. You can always find
ways to
tweak them, either to improve the readability of the output or to
improve the
plot.
In this quiz, I ask you to write your own story generator. You can start
with
Dwemthy’s Array, as I did, or invent your own characters and plot. The
only
requirement is that the generator must produce a different story each
time it is
run.
1: http://qa.poignantguide.net/chapter-6.html#section3