Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [QUIZ] Story Generator (#96)

Reply
Thread Tools

[QUIZ] Story Generator (#96)

 
 
Ruby Quiz
Guest
Posts: n/a
 
      09-29-2006
The three rules of Ruby Quiz:

1. Please do not post any solutions or spoiler discussion for this quiz until
48 hours have passed from the time on this message.

2. Support Ruby Quiz by submitting ideas as often as you can:

http://www.rubyquiz.com/

3. Enjoy!

Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone
on Ruby Talk follow the discussion. Please reply to the original quiz message,
if you can.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

by Morton Goldberg

[ 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

 
Reply With Quote
 
 
 
 
James Edward Gray II
Guest
Posts: n/a
 
      09-29-2006
On Sep 29, 2006, at 8:18 AM, Robert Dober wrote:

> On 9/29/06, Ruby Quiz <(E-Mail Removed)> wrote:
>>
>> The three rules of Ruby Quiz:
>>
>> <snip>

> The Quiz ittself might be too much work to do for me, but reading
> it was
> already an enourmous pleasure.


I too was worried it was too much effort before I ran it, but Morton
sent me his solution and it's not out-of-line with past quizzes.

We're not going for Pulitzer Prize winning publications here. Keep
it simple and see what you can get with a moderate effort.

Morton gives a great suggestion for where to steal code that will get
you started, but even without that you have a lot of options.
Remember grade school English? A subject, verb, and object is all
you really need.

Think outside the box. If your stories turn out comical, list that
as a feature in the quiz submission message, not a bug.

James Edward Gray II

P.S. For those of you that try this, posting generated stories is
not a spoiler!

 
Reply With Quote
 
 
 
 
Morton Goldberg
Guest
Posts: n/a
 
      09-30-2006
On Sep 29, 2006, at 9:18 AM, Robert Dober wrote:

> The Quiz ittself might be too much work to do for me, but reading
> it was
> already an enourmous pleasure.
> What a Funny, Great Idea!


I glad you like the idea. Please give it a try. It doesn't require
complex code, and it is even more fun to code this up than it is to
read the results.

Here is a surefire recipe for success

1. To a handful of goofy characters, add a list of silly things for
them to do
2. Season with your favorite cliches -- cliches are a key ingredient
3. Stir in a text editor until a suitably turgid consistency is reached
4. Run in a Ruby interpreter until done

Regards, Morton

 
Reply With Quote
 
Rick DeNatale
Guest
Posts: n/a
 
      09-30-2006
On 9/30/06, Morton Goldberg <(E-Mail Removed)> wrote:

> Here is a surefire recipe for success
>
> 1. To a handful of goofy characters, add a list of silly things for
> them to do
> 2. Season with your favorite cliches -- cliches are a key ingredient


Anyone else here old enough to remember MadLibs?


--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

 
Reply With Quote
 
M. Edward (Ed) Borasky
Guest
Posts: n/a
 
      09-30-2006
Rick DeNatale wrote:
> On 9/30/06, Morton Goldberg <(E-Mail Removed)> wrote:
>
>> Here is a surefire recipe for success
>>
>> 1. To a handful of goofy characters, add a list of silly things for
>> them to do
>> 2. Season with your favorite cliches -- cliches are a key ingredient

>
> Anyone else here old enough to remember MadLibs?
>
>

Roger Price ... of course. Do you remember Droodles?

 
Reply With Quote
 
James Edward Gray II
Guest
Posts: n/a
 
      09-30-2006
On Sep 30, 2006, at 9:08 AM, Rick DeNatale wrote:

> On 9/30/06, Morton Goldberg <(E-Mail Removed)> wrote:
>
>> Here is a surefire recipe for success
>>
>> 1. To a handful of goofy characters, add a list of silly things for
>> them to do
>> 2. Season with your favorite cliches -- cliches are a key ingredient

>
> Anyone else here old enough to remember MadLibs?


Sure:

http://www.rubyquiz.com/quiz28.html

James Edward Gray II

 
Reply With Quote
 
James Edward Gray II
Guest
Posts: n/a
 
      09-30-2006
On Sep 29, 2006, at 11:15 PM, Morton Goldberg wrote:

> It doesn't require complex code, and it is even more fun to code
> this up than it is to read the results.


I agree. I'm at 22 lines of code and I'm already laughing:

James kills Ruby. Ruby falls in love with James. James falls in
love
with James. Ruby slays James! James cries.

Shakespeare would be jealous for sure.

James Edward Gray II

 
Reply With Quote
 
Morton Goldberg
Guest
Posts: n/a
 
      09-30-2006
On Sep 30, 2006, at 11:14 AM, M. Edward (Ed) Borasky wrote:

> Roger Price ... of course. Do you remember Droodles?


Sure, this is one my favorites:

+-------------------+
| |
| |
| |
| . . |
| |
| |
| |
+-------------------+

Polar Bear in a Snowstorm

Regards, Morton



 
Reply With Quote
 
MonkeeSage
Guest
Posts: n/a
 
      09-30-2006
Mine is based on the 80's movie, Legend. My favorite output so far is:

"The Lord of Darkness undulates Princess Lily as the rain falls."

Oh my! Naughty Lord of Darkness! Heh.

Regards,
Jordan

 
Reply With Quote
 
Jim Menard
Guest
Posts: n/a
 
      10-01-2006
On 9/30/06, MonkeeSage <(E-Mail Removed)> wrote:
> Mine is based on the 80's movie, Legend. My favorite output so far is:
>
> "The Lord of Darkness undulates Princess Lily as the rain falls."
>
> Oh my! Naughty Lord of Darkness! Heh.
>
> Regards,
> Jordan


The approach I've taken is to modify my solution to Ruby Quiz #49 (the
Lisp Game) so it plays itself. The output is a random "story" that's
all plot and no characterization.

Jim
--
Jim Menard, http://www.velocityreviews.com/forums/(E-Mail Removed), (E-Mail Removed)
http://www.io.com/~jimm

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Story generator.... Terry Reedy Python 0 12-03-2007 07:27 PM
Tell Your Story - Wondershare Released Photo Story Platinum kena Digital Photography 0 06-12-2007 08:42 AM
[SUMMARY] Story Generator (#96) Ruby Quiz Ruby 0 10-05-2006 01:09 PM
UART with fractional baudrate generator ? Or fractional baudrate generator alone Martin Maurer VHDL 3 04-19-2006 01:26 PM
Newsweek Story just that a Story Mark Test Digital Photography 21 05-22-2005 02:39 PM



Advertisments