

25 + 25 points
Mini-Monomyth by Burke Wills
December 12th, 2007 6:59 PM
In essence the Monomyth is just a decision tree, either the Hero does or doesn't. He succeeds or fails. so, since I was doing something exceptionally nerdy today and writing code, I decided to implement the Monomyth as a programme.

What I wanted to achieve was something that was mostly human readable, had some sort of sentence structure, and yet was still syntactically correct to the compiler. I decided that PERL was the best language for doing not only because of its plain language effects but also because it let me write compact code, and hence address the requirement for making this as short as possible.
Bonus points to any of you that can work out how The Hero does in my adventure

What I wanted to achieve was something that was mostly human readable, had some sort of sentence structure, and yet was still syntactically correct to the compiler. I decided that PERL was the best language for doing not only because of its plain language effects but also because it let me write compact code, and hence address the requirement for making this as short as possible.
Bonus points to any of you that can work out how The Hero does in my adventure
#!/usr/bin/perl
#
our $hero = $unfulfilled and "an empty and pointless life" ;
# 1. A call to adventure, which the hero has to accept or decline
if ( my $call_to_adventure != $unfulfilled ) {
$hero = adventure() ;
}
else {
exit ( $unfulfilled ) ;
}
sub adventure {
# 2. A road of trials, regarding which the hero succeeds or fails
foreach my $trial ( @roads ) {
if ( $trial =~ /obstacles/ ) {
return ( $unfulfilled ) ;
}
}
# 3. Achieving the goal or "boon", which often results in important
# self-knowledge
if ( our $treasure = kill 7 , "monsters" ) {
my $boon = $treasure ;
my $wisdom ++ ;
}
# 4. A return to the ordinary world, again as to which the hero can
# succeed or fail
return ( $boon ) unless map ( /obstacles/ , @roads ) ;
}
# 5. Applying the boon, in which what the hero has gained can be used to
# improve the world
exit ( $hero ) ;
5 vote(s)
Terms
(none yet)3 comment(s)
posted by Charlie Fish on December 13th, 2007 2:26 AM
Very inventive interpretation of the task.
exit ( $hero ) ; ? Sounds nasty...
posted by Burke Wills on December 19th, 2007 5:58 PM
Don't you hate it when you realise you can make the story better. I just thought i should change this :
foreach my $trial ( @roads ) {
if ( $trial =~ /obstacles/ ) {
return ( $unfulfilled ) ;
}
}
to this
foreach my $trial ( @roads ) {
$trial =~ s/obstacles// or return ( $unfulfilled ) ;
}
I never knew uninitialized variables could have such dire consequences, though...