#!/usr/bin/perl -w # /home/sites/www.in-vacua.com/web/cgi-bin/rabbit_all.pl -w use CGI qw(:all); use strict; ################################################################################## # # # 'rabbit_all.pl' (description: generates versions of the Little Grey Rabbit - date: # early 1960's - stories by Professor Mendoza) # Copyright (C) 2020 Wayne Clements # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # See . # # The program is presented as it is on my website. # The html and links are as per in-vacua.com. You can change this as necessary. # # I'd appreciate a credit if you use any of the code. # # Wayne Clements, www.in-vacua.com. email: invacua_at__btinternet[Do T]com # ################################################################################ ################################### SUB 1 ####################################### sub p1s1 { my @listnames = ('The clouds', 'The sun', 'The breeze', 'The sky'); my $thing = $listnames[int(rand(@listnames))]; my %secondweight; if ($thing =~ /The clouds/) { %secondweight= ( "moved" => 1, "drifted" => 1, "shone" => 0, "floated" => 1, "touched" => 0, "melted" => 0, "looked down" => 1, "warmed" => 0, ) }; if ($thing =~ /The sun/) { %secondweight= ( "moved" => 1, "drifted" => 1, "shone" => 1, "floated" => 0, "touched" => 0, "melted" => 0, "looked down" => 1, "warmed" => 0, ) }; if ($thing =~ /The breeze/) { %secondweight= ( "moved" => 1, "drifted" => 1, "shone" => 0, "floated" => 1, "touched" => 0, "melted" => 0, "looked down" => 0, "warmed" => 0, ) }; if ($thing =~ /The sky/) { %secondweight= ( "moved" => 1, "drifted" => 0, "shone" => 0, "floated" => 0, "touched" => 0, "melted" => 0, "looked down" => 1, "warmed" => 0, ) }; my @listthing; foreach $thing(keys %secondweight) { push @listthing, ($thing) x $secondweight{$thing}; } my $action2 = $listthing[int(rand(@listthing))]; ################################### my %adverb2; if ($action2 =~ /moved/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 0, "then" => 1, " " => 2, ) }; if ($action2 =~ /drifted/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 0, "then" => 1, " " => 2, ) }; if ($action2 =~ /shone/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 0, "then" => 1, " " => 2, ) }; if ($action2 =~ /floated/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" =>0, "then" => 1, " " => 2, ) }; if ($action2 =~ /touched/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 0, "then" => 1, " " => 2, ) }; if ($action2 =~ /melted/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 0, "then" => 1, " " => 2, ) }; if ($action2 =~ /looked down/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 0, "then" => 0, " " => 2, ) }; if ($action2 =~ /warmed/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 0, "then" => 1, " " => 2, ) }; my @adverbchoice2; foreach my $action2 (keys %adverb2) { push @adverbchoice2, ($action2) x $adverb2{$action2}; } my $what = $adverbchoice2[int(rand(@adverbchoice2))]; ######################## my %verb2; if ($what =~ /gently/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 0, "all day" => 1, "all afternoon" => 1, ) }; if ($what =~ /quietly/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 0, "all day" => 1, "all afternoon" => 1, ) }; if ($what =~ /loudly/) { %verb2 = ( "by" => 0, "over the woods" => 0, "across the meadows" => 0, "through the trees" => 0, "down" => 0, "for a long time" => 0, "all day" => 0, "all afternoon" => 0, ) }; if ($what =~ /softly/) { %verb2 =( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($what =~ /calmly/) { %verb2 = ( "by" =>0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($what =~ /soon/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($what =~ /then/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($what =~ / /) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; my @verb2choice; foreach $what(keys %verb2) { push @verb2choice, ($what) x $verb2{$what}; } my $newword2 = $verb2choice[int(rand(@verb2choice))]; ############################ my @p1s1 =($thing,' ',$action2, ' ', $what,' ', $newword2,'. '); my $whatnot = join " ", @p1s1; $whatnot =~ s/\s+/ /g; $whatnot =~ s/\s+\./\./g; print $whatnot; } ################################### SUB 2 ########################################### sub p1s2 { my @listevent = ('Over the woods', 'Across the fields', 'Through the trees', 'Down', 'For a long time', 'All day', 'All afternoon'); my $event = $listevent[int(rand(@listevent))]; #print $event; my @listnames = ('the clouds', 'the sun', 'the breeze', 'the sky'); my $thing = $listnames[int(rand(@listnames))]; my %secondweight; if ($thing =~ /the clouds/) { %secondweight= ( "moved" => 1, "drifted" => 1, "shone" => 0, "floated" => 1, "touched" => 0, "melted" => 0, "looked down" => 0, "warmed" => 0, ) }; if ($thing =~ /the sun/) { %secondweight= ( "moved" => 0, "drifted" => 1, "shone" => 1, "floated" => 0, "touched" => 0, "melted" => 0, "looked down" => 0, "warmed" => 1, ) }; if ($thing =~ /the breeze/) { %secondweight= ( "moved" => 1, "drifted" => 1, "shone" => 0, "floated" => 1, "touched" => 0, "melted" => 0, "looked down" => 0, "warmed" => 0, ) }; if ($thing =~ /the sky/) { %secondweight= ( "moved" => 0, "drifted" => 1, "shone" => 0, "floated" => 1, "touched" => 0, "melted" => 0, "looked down" => 0, "warmed" => 0, ) }; ################# my @listthing; foreach my $thing(keys %secondweight) { push @listthing, ($thing) x $secondweight{$thing}; } my $action2 = $listthing[int(rand(@listthing))]; ################################### my %adverb2; if ($action2 =~ /moved/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, "" => 2, ) }; if ($action2 =~ /drifted/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, "" => 2, ) }; if ($action2 =~ /shone/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, "" => 2, ) }; if ($action2 =~ /floated/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, "" => 2, ) }; if ($action2 =~ /touched/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, "" => 2, ) }; if ($action2 =~ /melted/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, "" => 2, ) }; if ($action2 =~ /looked down/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, "" => 2, ) }; if ($action2 =~ /warmed/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, "" => 2, ) }; ############################################ my @adverbchoice2; foreach my $action2 (keys %adverb2) { push @adverbchoice2, ($action2) x $adverb2{$action2}; } my $newword = $adverbchoice2[int(rand(@adverbchoice2))]; my @more = ("and", "while"); my $morewords = $more[int(rand(@more))]; my @p1s2 =($event, ' ', $newword, ' ', $action2, ' ', $thing, ' ', $morewords,' '); my $whatnot = join " ", @p1s2; $whatnot =~ s/\s+/ /g; print $whatnot; } ################################# SUB 3 ################################## sub p1s3 { my @listnames = ('the clouds', 'the sun', 'the breeze', 'the sky'); my $thing = $listnames[int(rand(@listnames))]; my %secondweight; if ($thing =~ /the clouds/) { %secondweight= ( "moved" => 1, "drifted" => 1, "shone" => 0, "floated" => 1, "touched" => 0, "melted" => 0, "looked down" => 1, "warmed" => 0, ) }; if ($thing =~ /the sun/) { %secondweight= ( "moved" => 0, "drifted" => 1, "shone" => 1, "floated" => 0, "touched" => 0, "melted" => 0, "looked down" => 1, "warmed" => 1, ) }; if ($thing =~ /the breeze/) { %secondweight= ( "moved" => 1, "drifted" => 1, "shone" => 0, "floated" => 1, "touched" => 0, "melted" => 0, "looked down" => 0, "warmed" => 0, ) }; if ($thing =~ /the sky/) { %secondweight= ( "moved" => 1, "drifted" => 0, "shone" => 0, "floated" => 0, "touched" => 0, "melted" => 0, "looked down" => 1, "warmed" => 0, ) }; my @listthing; foreach $thing(keys %secondweight) { push @listthing, ($thing) x $secondweight{$thing}; } my $action2 = $listthing[int(rand(@listthing))]; ################################### my %adverb2; if ($action2 =~ /moved/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, " " => 2, ) }; if ($action2 =~ /drifted/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, " " => 2, ) }; if ($action2 =~ /shone/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, " " => 2, ) }; if ($action2 =~ /floated/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, " " => 2, ) }; if ($action2 =~ /touched/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, " " => 2, ) }; if ($action2 =~ /melted/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, " " => 2, ) }; if ($action2 =~ /looked down/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, " " => 2, ) }; if ($action2 =~ /warmed/) { %adverb2 = ( "gently" => 1, "quietly" => 1, "loudly" => 0, "softly" => 1, "calmly" => 1, "soon" => 1, "then" => 1, " " => 2, ) }; my @adverbchoice2; foreach $action2 (keys %adverb2) { push @adverbchoice2, ($action2) x $adverb2{$action2}; } my $newword = $adverbchoice2[int(rand(@adverbchoice2))]; ############################# my %verb2; if ($action2 =~ /moved/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 0, "all day" => 1, "all afternoon" => 1, ) }; if ($action2=~ /drifted/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 0, "all day" => 1, "all afternoon" => 1, ) }; if ($action2 =~ /shone/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 1, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($action2 =~ /floated/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($action2 =~ /touched/) { %verb2 = ( "by" => 0, "the woods" => 1, "the meadows" => 1, "the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($action2 =~ /melted/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($action2 =~ /looked down/) { %verb2 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($action2 =~ /warmed/) { %verb2 = ( "by" => 0, "the woods" => 1, "the meadows" => 1, "the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; my @verb2choice; foreach $action2 (keys %verb2) { push @verb2choice, ($action2) x $verb2{$action2}; } my $newword2 = $verb2choice[int(rand(@verb2choice))]; #print $newword2; ####################################################################################### my %thirdweight; if ($thing =~ /the clouds/) { %thirdweight= ( "moved" => 1, "drifted" => 1, "shone" => 0, "floated" => 1, "touched" => 0, "melted" => 0, "looked down" => 1, "warmed" => 0, ) }; if ($thing =~ /the sun/) { %thirdweight= ( "moved" => 0, "drifted" => 1, "shone" => 1, "floated" => 0, "touched" => 1, "melted" => 0, "looked down" => 1, "warmed" => 1, ) }; if ($thing =~ /the breeze/) { %thirdweight= ( "moved" => 1, "drifted" => 1, "shone" => 0, "floated" => 1, "touched" => 1, "melted" => 0, "looked down" => 0, "warmed" => 0, ) }; if ($thing =~ /the sky/) { %thirdweight= ( "moved" => 1, "drifted" => 0, "shone" => 0, "floated" => 0, "touched" => 0, "melted" => 0, "looked down" => 1, "warmed" => 0, ) }; my @listthing3; foreach $thing(keys %thirdweight) { push @listthing3, ($thing) x $thirdweight{$thing}; } my $action3 = $listthing3[int(rand(@listthing3))]; ###################################################################################### my %verb3; if ($action3 =~ /moved/) { %verb3 = ( "by" => 1, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 0, "all day" => 1, "all afternoon" => 1, ) }; if ($action3=~ /drifted/) { %verb3 = ( "by" => 1, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 0, "all day" => 1, "all afternoon" => 1, ) }; if ($action3=~ /shone/) { %verb3 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 1, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($action3 =~ /floated/) { %verb3 = ( "by" => 1, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($action3 =~ /touched/) { %verb3 = ( "by" => 0, "the woods" => 1, "the meadows" => 1, "the trees" => 1, "down" => 0, "for a long time" => 0, "all day" => 0, "all afternoon" => 0, ) }; if ($action3=~ /melted/) { %verb3 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 0, "all day" => 1, "all afternoon" => 1, ) }; if ($action3=~ /looked down/) { %verb3 = ( "by" => 0, "over the woods" => 1, "across the meadows" => 1, "through the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; if ($action3 =~ /warmed/) { %verb3 = ( "by" => 0, "the woods" => 1, "the meadows" => 1, "the trees" => 1, "down" => 0, "for a long time" => 1, "all day" => 1, "all afternoon" => 1, ) }; my @verb2choice_b; foreach $action3(keys %verb3) { push @verb2choice_b, ($action3) x $verb3{$action3}; } my $newword3 = $verb2choice_b[int(rand(@verb2choice_b))]; ############################ my @p1s3 =('then',' ', $thing,' ', 'which ', $newword,' ' , $action2, ' ', $newword2, ' ', $action3, ' ', $newword3,'.' ,'
', '
'); my $whatnot = join " ", @p1s3; $whatnot =~ s/\s+/ /g; $whatnot =~ s/ ,/,/g; $whatnot =~ s/\s+\./\./g; $whatnot =~ s/^\s+//; $whatnot =~ s/\s+$//; print $whatnot; } ################################### SUB 4 ################################### sub p4s4 { my @listnames = ('Little Grey Rabbit', 'Old Grey Owl', 'Squirrel', 'Hare'); my $animal = $listnames[int(rand(@listnames))]; ################################################## my %secondweight; if ($animal =~ /Little Grey Rabbit/) { %secondweight= ( "scampered" => 1, "flew" => 0, "ran" => 2, "hurried" => 3, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 2, ) }; if ($animal =~ /Old Grey Owl/) { %secondweight= ( "scampered" => 0, "flew" => 3, "ran" => 0, "hurried" => 0, "sniffed at" => 1, "peered at" => 3, "ate" => 2, "munched and crunched" => 2, ) }; if ($animal =~ /Squirrel/) { %secondweight= ( "scampered" => 3, "flew" => 0, "ran" => 1, "hurried" => 1, "sniffed at" => 1, "peered at" => 1, "ate" => 3, "munched and crunched" => 3, ) }; if ($animal =~ /Hare/) { %secondweight= ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 2, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 2, ) }; my @listanimal; foreach my $animal(keys %secondweight) { push @listanimal, ($animal) x $secondweight{$animal}; } my $action2 = $listanimal[int(rand(@listanimal))]; ####################################### my %verb2; my $newnext = $action2; if ($newnext =~ /scampered/) { %verb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 1, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext =~ /flew/) { %verb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 2, "among the treetops" => 1, "into the home" => 0, "out of the door" => 0, "down the path to the woods" => 0, "about the garden" => 0, ) }; if ($newnext =~ /ran/) { %verb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext =~ /hurried/) { %verb2 = ( "off" => 1, "through the trees" => 0, "over the woods and fields" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext =~ /sniffed at/) { %verb2 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($newnext =~ /peered at/) { %verb2 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($newnext =~ /ate/) { %verb2 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($newnext =~ /munched and crunched/) { %verb2 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; my @verb2choice; foreach $newnext (keys %verb2) { push @verb2choice, ($newnext) x $verb2{$newnext}; } my $newword2 = $verb2choice[int(rand(@verb2choice))]; my %verb3; if ($animal =~ /Little Grey Rabbit/) { %verb3 = ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; if ($animal =~ /Old Grey Owl/) { %verb3 = ( "scampered" => 0, "flew" => 1, "ran" => 0, "hurried" => 0, ) }; if ($animal =~ /Squirrel/) { %verb3 = ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; if ($animal =~ /Hare/) { %verb3 = ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; my @verb3choice; foreach $animal (keys %verb3) { push @verb3choice, ($animal) x $verb3{$animal}; } my $newword3 = $verb3choice[int(rand(@verb3choice))]; #chooses one from array ################################################## my @adverb1 = ('then', 'slowly', 'quickly', 'happily', 'gaily', 'noisily'); if ($newword3 =~ "hurried") { @adverb1 = grep (!/slowly/, @adverb1); } if ($newword3 =~ "ran") { @adverb1 = grep (!/slowly/, @adverb1); } my $firstadverb = $adverb1[int(rand(@adverb1))]; ################################################### my %animal2; if ($animal =~ /Little Grey Rabbit/) { %animal2 = ( "Little Grey Rabbit" => 0, "Old Grey Owl" => 1, "Squirrel" => 1, "Hare" => 1, ) }; if ($animal =~ /Old Grey Owl/) { %animal2 = ( "Little Grey Rabbit" => 1, "Old Grey Owl" => 0, "Squirrel" => 1, "Hare" => 1, ) }; if ($animal =~ /Squirrel/) { %animal2 = ( "Little Grey Rabbit" => 1, "Old Grey Owl" => 1, "Squirrel" => 0, "Hare" => 1, ) }; if ($animal =~ /Hare/) { %animal2 = ( "Little Grey Rabbit" => 1, "Old Grey Owl" => 1, "Squirrel" => 1, "Hare" => 0, ) }; my @animal2choice; foreach $animal (keys %animal2) { push @animal2choice, ($animal) x $animal2{$animal}; } my $secondanimal = $animal2choice[int(rand(@animal2choice))]; ######################################################################## my %verb4; if ($secondanimal =~ /Little Grey Rabbit/) { %verb4 = ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; if ($secondanimal =~ /Old Grey Owl/) { %verb4 = ( "scampered" => 0, "flew" => 1, "ran" => 0, "hurried" => 0, ) }; if ($secondanimal =~ /Squirrel/) { %verb4 = ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; if ($secondanimal =~ /Hare/) { %verb4 = ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; ########### my @verb4choice; foreach $secondanimal (keys %verb4) { push @verb4choice, ($secondanimal) x $verb4{$secondanimal}; } my $doingword1 = $verb4choice[int(rand(@verb4choice))]; ######################################################################## my @adverb2 = ('then', 'slowly', 'quickly', 'happily', 'gaily', 'noisily'); if ($doingword1 =~ "hurried") { @adverb2 = grep (!/slowly/, @adverb2); } if ($doingword1 =~ "ran") { @adverb2 = grep (!/slowly/, @adverb2); } my $secondadverb = $adverb2[int(rand(@adverb2))]; ######################################################################## my $pronoun; if ($secondanimal =~ /Hare/) { $pronoun = 'He'}; if ($secondanimal =~ /Owl/) { $pronoun = 'He'}; if ($secondanimal =~ /Squirrel/) { $pronoun = 'She'}; if ($secondanimal =~ /Little Grey Rabbit/) { $pronoun = 'She'}; ################################# my %nthweight1; if ($secondanimal =~ /Little Grey Rabbit/) { %nthweight1 = ( "scampered" => 1, "flew" => 0, "ran" => 2, "hurried" => 3, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 0, ) }; if ($secondanimal =~ /Old Grey Owl/) { %nthweight1= ( "scampered" => 0, "flew" => 3, "ran" => 0, "hurried" => 0, "sniffed at" => 1, "peered at" => 3, "ate" => 2, "munched and crunched" => 2, ) }; if ($secondanimal =~ /Squirrel/) { %nthweight1= ( "scampered" => 3, "flew" => 0, "ran" => 1, "hurried" => 1, "sniffed at" => 1, "peered at" => 1, "ate" => 3, "munched and crunched" => 3, ) }; if ($secondanimal =~ /Hare/) { %nthweight1= ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 2, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 2, ) }; my @listsecondanimal; foreach my $secondanimal(keys %nthweight1) { push @listsecondanimal, ($secondanimal) x $nthweight1{$secondanimal}; } my $nthaction1 = $listsecondanimal[int(rand(@listsecondanimal))]; ####################################### my %nthverb1; my $nthnext1 = $nthaction1; if ($nthnext1 =~ /scampered/) { %nthverb1 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 1, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext1 =~ /flew/) { %nthverb1 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 2, "among the treetops" => 1, "into the home" => 0, "out of the door" => 0, "down the path to the woods" => 0, "about the garden" => 0, ) }; if ($nthnext1 =~ /ran/) { %nthverb1 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext1 =~ /hurried/) { %nthverb1 = ( "off" => 1, "through the trees" => 0, "over the woods and fields" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext1 =~ /sniffed at/) { %nthverb1 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext1 =~ /peered at/) { %nthverb1 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext1 =~ /ate/) { %nthverb1 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext1 =~ /munched and crunched/) { %nthverb1 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; my @nthverb1choice; foreach $nthnext1 (keys %nthverb1) { push @nthverb1choice, ($nthnext1) x $nthverb1{$nthnext1}; } my $nthword1 = $nthverb1choice[int(rand(@nthverb1choice))]; #chooses one from array #################################### my @array = ('Squirrel', 'Hare', 'Old Grey Owl', 'Little Grey Rabbit'); @array = grep {!/$animal/} @array; @array = grep {!/$secondanimal/} @array; my $animal3 = $array[int(rand(@array))]; ################################################## my %secondweight3; if ($animal3 =~ /Little Grey Rabbit/) { %secondweight3= ( "scampered" => 1, "flew" => 0, "ran" => 2, "hurried" => 3, ) }; if ($animal3 =~ /Old Grey Owl/) { %secondweight3= ( "scampered" => 0, "flew" => 3, "ran" => 0, "hurried" => 0, ) }; if ($animal3 =~ /Squirrel/) { %secondweight3= ( "scampered" => 3, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; if ($animal3 =~ /Hare/) { %secondweight3= ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 2, ) }; my @listanimal3; foreach my $animal3(keys %secondweight3) { push @listanimal3, ($animal3) x $secondweight3{$animal3}; } my $action4 = $listanimal3[int(rand(@listanimal3))]; ##################################### my @adverb3; @adverb3 = ('then', 'slowly', 'quickly', 'happily', 'gaily', 'noisily'); if ($action4 =~ "hurried") { @adverb3 = grep (!/slowly/, @adverb3); } if ($action4 =~ "ran") { @adverb3 = grep (!/slowly/, @adverb3); } my $otheradverb = $adverb3[int(rand(@adverb3))]; ####################################### my %verbchanged; my $newnext4 = $action4; if ($newnext4 =~ /scampered/) { %verbchanged = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext4 =~ /flew/) { %verbchanged = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 2, "among the treetops" => 0, "into the home" => 0, "out of the door" => 0, "down the path to the woods" => 0, "about the garden" => 0, ) }; if ($newnext4 =~ /ran/) { %verbchanged = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext4 =~ /hurried/) { %verbchanged = ( "off" => 1, "through the trees" => 0, "over the woods and fields" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; my @verb5choice; foreach $newnext4 (keys %verbchanged) { push @verb5choice, ($newnext4) x $verbchanged{$newnext4}; } my $newword4 = $verb5choice[int(rand(@verb5choice))]; ############ my %nthweight2; if ($animal3 =~ /Little Grey Rabbit/) { %nthweight2= ( "scampered" => 1, "flew" => 0, "ran" => 2, "hurried" => 3, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 0, ) }; if ($animal3 =~ /Old Grey Owl/) { %nthweight2= ( "scampered" => 0, "flew" => 3, "ran" => 0, "hurried" => 0, "sniffed at" => 1, "peered at" => 3, "ate" => 2, "munched and crunched" => 2, ) }; if ($animal3 =~ /Squirrel/) { %nthweight2= ( "scampered" => 3, "flew" => 0, "ran" => 1, "hurried" => 1, "sniffed at" => 1, "peered at" => 1, "ate" => 3, "munched and crunched" => 3, ) }; if ($animal3 =~ /Hare/) { %nthweight2= ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 2, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 2, ) }; my @listanimal5; foreach my $animal3(keys %nthweight2) { push @listanimal5, ($animal3) x $nthweight2{$animal3}; } my $nthaction2 = $listanimal5[int(rand(@listanimal5))]; ####################################### my %nthverb2; my $nthnext2 = $nthaction2; if ($nthnext2 =~ /scampered/) { %nthverb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext2 =~ /flew/) { %nthverb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 2, "among the treetops" => 1, "into the home" => 0, "out of the door" => 0, "down the path to the woods" => 0, "about the garden" => 0, ) }; if ($nthnext2 =~ /ran/) { %nthverb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext2 =~ /hurried/) { %nthverb2 = ( "off" => 1, "through the trees" => 0, "over the woods and fields" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext2 =~ /sniffed at/) { %nthverb2 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext2 =~ /peered at/) { %nthverb2 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext2 =~ /ate/) { %nthverb2 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext2 =~ /munched and crunched/) { %nthverb2 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; my @nthverb2choice; foreach $nthnext2 (keys %nthverb2) { push @nthverb2choice, ($nthnext2) x $nthverb2{$nthnext2}; } my $nthword2 = $nthverb2choice[int(rand(@nthverb2choice))]; #chooses one from array ####################################### my @adverb4 = ('then', 'slowly', 'quickly', 'happily', 'gaily', 'noisily'); if ($nthaction2 =~ "hurried") { @adverb4 = grep (!/slowly/, @adverb4); } if ($nthaction2 =~ "ran") { @adverb4 = grep (!/slowly/, @adverb4); } my $anotheradverb = $adverb4[int(rand(@adverb4))]; #chooses one from array my @p4s4 =($animal,' ','who',' ',$action2, ' ', $newword2, ' ', $firstadverb, ' ', $newword3, ' ', 'off and off',' ',$secondadverb, ' ',$doingword1, ' ', $secondanimal,'.',' ',$pronoun,' ',$nthaction1, ' ', $nthword1, ' ','but',' ', $newword4,' ', $otheradverb, ' ', $action4, ' ', $animal3, ' ', 'who',' ', $nthaction2,' ', $anotheradverb,' ', $nthword2,'.',' '); print @p4s4; } ################################### SUB 5 ################################### sub p5s5 { my @listnames = ('Little Grey Rabbit', 'Old Grey Owl', 'Squirrel', 'Hare'); my $animal = $listnames[int(rand(@listnames))]; #chooses one from array ################################################## my %secondweight; if ($animal =~ /Little Grey Rabbit/) { %secondweight = ( "scampered" => 1, "flew" => 0, "ran" => 2, "hurried" => 3, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 0, ) }; if ($animal =~ /Old Grey Owl/) { %secondweight= ( "scampered" => 0, "flew" => 3, "ran" => 0, "hurried" => 0, "sniffed at" => 1, "peered at" => 3, "ate" => 2, "munched and crunched" => 2, ) }; if ($animal =~ /Squirrel/) { %secondweight= ( "scampered" => 3, "flew" => 0, "ran" => 1, "hurried" => 1, "sniffed at" => 1, "peered at" => 1, "ate" => 3, "munched and crunched" => 3, ) }; if ($animal =~ /Hare/) { %secondweight= ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 2, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 2, ) }; my @listanimal; foreach my $animal(keys %secondweight) { push @listanimal, ($animal) x $secondweight{$animal}; } my $action2 = $listanimal[int(rand(@listanimal))]; ####################################### my %verb2; my $newnext = $action2; if ($newnext =~ /scampered/) { %verb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext =~ /flew/) { %verb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 2, "among the treetops" => 1, "into the home" => 0, "out of the door" => 0, "down the path to the woods" => 0, "about the garden" => 0, ) }; if ($newnext =~ /ran/) { %verb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 0, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext =~ /hurried/) { %verb2 = ( "off" => 1, "through the trees" => 0, "over the woods and fields" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext =~ /sniffed at/) { %verb2 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($newnext =~ /peered at/) { %verb2 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($newnext =~ /ate/) { %verb2 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($newnext =~ /munched and crunched/) { %verb2 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; my @verb2choice; foreach $newnext (keys %verb2) { push @verb2choice, ($newnext) x $verb2{$newnext}; } my $newword2 = $verb2choice[int(rand(@verb2choice))]; ################################################## my @adverb1 = ('then', 'slowly', 'quickly', 'happily', 'gaily', 'noisily'); if ($action2 =~ "peered at") { @adverb1 = grep (!/noisily/, @adverb1); } if ($action2 =~ "hurried") { @adverb1 = grep (!/slowly/, @adverb1); } if ($action2 =~ "ran") { @adverb1 = grep (!/slowly/, @adverb1); } my $firstadverb = $adverb1[int(rand(@adverb1))]; ################################################### my %animal2; if ($animal =~ /Little Grey Rabbit/) { %animal2 = ( "Little Grey Rabbit" => 0, "Old Grey Owl" => 1, "Squirrel" => 1, "Hare" => 1, ) }; if ($animal =~ /Old Grey Owl/) { %animal2 = ( "Little Grey Rabbit" => 1, "Old Grey Owl" => 0, "Squirrel" => 1, "Hare" => 1, ) }; if ($animal =~ /Squirrel/) { %animal2 = ( "Little Grey Rabbit" => 1, "Old Grey Owl" => 1, "Squirrel" => 0, "Hare" => 1, ) }; if ($animal =~ /Hare/) { %animal2 = ( "Little Grey Rabbit" => 1, "Old Grey Owl" => 1, "Squirrel" => 1, "Hare" => 0, ) }; my @animal2choice; foreach $animal (keys %animal2) { push @animal2choice, ($animal) x $animal2{$animal}; } my $secondanimal = $animal2choice[int(rand(@animal2choice))]; ######################################################################## my %verb4; if ($secondanimal =~ /Little Grey Rabbit/) { %verb4 = ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; if ($secondanimal =~ /Old Grey Owl/) { %verb4 = ( "scampered" => 0, "flew" => 1, "ran" => 0, "hurried" => 0, ) }; if ($secondanimal =~ /Squirrel/) { %verb4 = ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; if ($secondanimal =~ /Hare/) { %verb4 = ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; ########### my @verb4choice; foreach $secondanimal (keys %verb4) { push @verb4choice, ($secondanimal) x $verb4{$secondanimal}; } my $doingword1 = $verb4choice[int(rand(@verb4choice))]; ######################################################################## my %nthweight1; if ($secondanimal =~ /Little Grey Rabbit/) { %nthweight1= ( "scampered" => 1, "flew" => 0, "ran" => 2, "hurried" => 3, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 0, ) }; if ($secondanimal =~ /Old Grey Owl/) { %nthweight1= ( "scampered" => 0, "flew" => 3, "ran" => 0, "hurried" => 0, "sniffed at" => 1, "peered at" => 3, "ate" => 2, "munched and crunched" => 2, ) }; if ($secondanimal =~ /Squirrel/) { %nthweight1= ( "scampered" => 3, "flew" => 0, "ran" => 1, "hurried" => 1, "sniffed at" => 1, "peered at" => 1, "ate" => 3, "munched and crunched" => 3, ) }; if ($secondanimal =~ /Hare/) { %nthweight1= ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 2, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 2, ) }; my @listsecondanimal; foreach my $secondanimal(keys %nthweight1) { push @listsecondanimal, ($secondanimal) x $nthweight1{$secondanimal}; } my $nthaction1 = $listsecondanimal[int(rand(@listsecondanimal))]; ################## my %nthverb1; my $nthnext1 = $doingword1; if ($nthnext1 =~ /scampered/) { %nthverb1 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext1 =~ /flew/) { %nthverb1 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 2, "among the treetops" => 1, "into the home" => 0, "out of the door" => 0, "down the path to the woods" => 0, "about the garden" => 0, ) }; if ($nthnext1 =~ /ran/) { %nthverb1 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext1 =~ /hurried/) { %nthverb1 = ( "off" => 1, "through the trees" => 0, "over the woods and fields" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext1 =~ /sniffed at/) { %nthverb1 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext1 =~ /peered at/) { %nthverb1 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext1 =~ /ate/) { %nthverb1 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext1 =~ /munched and crunched/) { %nthverb1 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; my @nthverb1choice; foreach $nthnext1 (keys %nthverb1) { push @nthverb1choice, ($nthnext1) x $nthverb1{$nthnext1}; } my $nthword1 = $nthverb1choice[int(rand(@nthverb1choice))]; #chooses one from array ###### ############################## my @array = ('Squirrel', 'Hare', 'Old Grey Owl', 'Little Grey Rabbit'); @array = grep {!/$animal/} @array; @array = grep {!/$secondanimal/} @array; my $animal3 = $array[int(rand(@array))]; ################################################## my %secondweight3; if ($animal3 =~ /Little Grey Rabbit/) { %secondweight3= ( "scampered" => 1, "flew" => 0, "ran" => 2, "hurried" => 3, ) }; if ($animal3 =~ /Old Grey Owl/) { %secondweight3= ( "scampered" => 0, "flew" => 3, "ran" => 0, "hurried" => 0, ) }; if ($animal3 =~ /Squirrel/) { %secondweight3= ( "scampered" => 3, "flew" => 0, "ran" => 1, "hurried" => 1, ) }; if ($animal3 =~ /Hare/) { %secondweight3= ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 2, ) }; my @listanimal3; foreach my $animal3(keys %secondweight3) { push @listanimal3, ($animal3) x $secondweight3{$animal3}; } my $action4 = $listanimal3[int(rand(@listanimal3))]; ###################################### ####################################### my %verbchanged; my $newnext4 = $action4; if ($newnext4 =~ /scampered/) { %verbchanged = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext4 =~ /flew/) { %verbchanged = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext4 =~ /ran/) { %verbchanged = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($newnext4 =~ /hurried/) { %verbchanged = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; my @verbchangedchoice; foreach $newnext4 (keys %verb4) { push @verbchangedchoice, ($newnext4) x $verb4{$newnext4}; } my $newword4 = $verbchangedchoice[int(rand(@verbchangedchoice))]; ##################################### my %verb5; my $newnext5 = $action4; if ($newnext5 =~ /scampered/) { %verb5 = ( "Off" => 1, "Over the woods and fields" => 1, "Through the trees" => 1, "Among the treetops" => 0, "Into the home" => 0, "Out of the door" => 1, "Down the path to the woods" => 1, "About the garden" => 1, ) }; if ($newnext5 =~ /flew/) { %verb5 = ( "Off" => 1, "Over the woods and fields" => 1, "Through the trees" => 1, "Among the treetops" => 0, "Into the home" => 0, "Out of the door" => 1, "Down the path to the woods" => 1, "About the garden" => 1, ) }; if ($newnext5 =~ /ran/) { %verb5 = ( "Off" => 1, "Over the woods and fields" => 1, "Through the trees" => 1, "Among the treetops" => 0, "Into the home" => 0, "Out of the door" => 1, "Down the path to the woods" => 1, "About the garden" => 1, ) }; if ($newnext5 =~ /hurried/) { %verb5 = ( "Off" => 1, "Over the woods and fields" => 1, "Through the trees" => 1, "Among the treetops" => 0, "Into the home" => 0, "Out of the door" => 1, "Down the path to the woods" => 1, "About the garden" => 1, ) }; my @verb5choice; foreach $newnext5 (keys %verb5) { push @verb5choice, ($newnext5) x $verb5{$newnext5}; } my $newword5 = $verb5choice[int(rand(@verb5choice))]; ##################################### my %nthweight2; if ($animal3 =~ /Little Grey Rabbit/) { %nthweight2= ( "scampered" => 1, "flew" => 0, "ran" => 2, "hurried" => 3, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 0, ) }; if ($animal3 =~ /Old Grey Owl/) { %nthweight2= ( "scampered" => 0, "flew" => 3, "ran" => 0, "hurried" => 0, "sniffed at" => 1, "peered at" => 3, "ate" => 2, "munched and crunched" => 2, ) }; if ($animal3 =~ /Squirrel/) { %nthweight2= ( "scampered" => 3, "flew" => 0, "ran" => 1, "hurried" => 1, "sniffed at" => 1, "peered at" => 1, "ate" => 3, "munched and crunched" => 3, ) }; if ($animal3 =~ /Hare/) { %nthweight2= ( "scampered" => 1, "flew" => 0, "ran" => 1, "hurried" => 2, "sniffed at" => 1, "peered at" => 1, "ate" => 2, "munched and crunched" => 2, ) }; my @listanimal4; foreach my $animal3(keys %nthweight2) { push @listanimal4, ($animal3) x $nthweight2{$animal3}; } my $nthaction2 = $listanimal4[int(rand(@listanimal4))]; ############################################ my %nthverb2; my $nthnext2 = $nthaction2; if ($nthnext2 =~ /scampered/) { %nthverb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 0, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext2 =~ /flew/) { %nthverb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 2, "among the treetops" => 1, "into the home" => 0, "out of the door" => 0, "down the path to the woods" => 0, "about the garden" => 0, ) }; if ($nthnext2 =~ /ran/) { %nthverb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext2 =~ /hurried/) { %nthverb2 = ( "off" => 1, "over the woods and fields" => 1, "through the trees" => 1, "among the treetops" => 0, "into the home" => 1, "out of the door" => 1, "down the path to the woods" => 1, "about the garden" => 1, ) }; if ($nthnext2 =~ /sniffed at/) { %nthverb2 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext2 =~ /peered at/) { %nthverb2 = ( "the house" => 1, "the hollow tree" => 1, "an old oak tree" => 1, "the flowers" => 1, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext2 =~ /ate/) { %nthverb2 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; if ($nthnext2 =~ /munched and crunched/) { %nthverb2 = ( "the house" => 0, "the hollow tree" => 0, "an old oak tree" => 0, "the flowers" => 0, "two buns" => 1, "a strawberry pie" => 1, "six cabbages" => 1, ) }; my @nthverb2choice; foreach $nthnext2 (keys %nthverb2) { push @nthverb2choice, ($nthnext2) x $nthverb2{$nthnext2}; } my $nthword2 = $nthverb2choice[int(rand(@nthverb2choice))]; ####################################### my @adverb4 = ('then', 'slowly', 'quickly', 'happily', 'gaily', 'noisily'); if ($nthaction2 =~ "hurried") { @adverb4 = grep (!/slowly/, @adverb4); } if ($nthaction2 =~ "ran") { @adverb4 = grep (!/slowly/, @adverb4); } my $anotheradverb = $adverb4[int(rand(@adverb4))]; ####################################### my @p5s5 =($animal,' ', $firstadverb, ' ', $action2, ' ', $newword2, ' ', 'but', ' ', $secondanimal, ' ', $doingword1, ' ', $nthword1,'.', ' ',$newword5,' ',$action4, ' ',$animal3,' ','who',' ', $anotheradverb, ' ',$nthaction2, ' ', $nthword2,'.'); print @p5s5; } ################################## print "Content-type: text/html\n\n"; print "Grey Rabbit
Little Grey Rabbit

A version of the Little Grey Rabbit stories, by Professor Mendoza


"; p1s1(); p1s2(); p1s3(); p4s4(); p5s5(); print "



Little Grey Rabbit stories are discussed in the Catalogue of Cybernetic Serendipity, ICA Gallery, 1968.
They are (very) short stories written by a computer program. The Little Grey Rabbit stories are an interesting early example
of computer generated fiction. They are now almost entirely forgotten. The stories were the work of Professor Eric Mendoza
and date from the early 1960's.

The stories seem never to have been published. All that may remain of them are the examples given in the catalogue
and the description of aspects of their programming. Only two outputs are reproduced. This is one example:

'The sun shone over the woods.
Across the fields softly drifted
the breeze while then the clouds which
calmly floated all afternoon moved
across the fields.

Squirrel who scampered through the
trees quickly ran offand off noisily
ran Little Grey Rabbit. She sniffed at
the house but out of the door noisily hurried
Hare who peered at slowly the flowers.
Squirrel quickly scampered over the woods
and fields but Old Grey Owl flew over
the woods and fields.Down the path to
the woods ran Little Grey Rabbit
who then sniffed at a stawberry pie.'



My program emulates the construction of these paragraphs.



Professor Mendoza recounts his program writing:

'...very boring stories that did not even satisfy my youngest children...
I tried these stories on my very small children but after some minutes they grew very irritable,
because nothing actually happened. This shows that even small children of three can measure entropy'



It is the poetry of this entropic tedium that I hope is preserved in my program.
Repetitions and oddities seem to be inherent in the program logic.

Professor Mendoza's original program for the Little Grey Rabbit stories seems also to be missing.
I have replicated its functioning using Perl. Professor Mendoza presents
some of the structure of his program in the form of probability matrices. I have
created a version of these matrices in my program.

The code is here

A variant version ('Nocturne') is here.

There is a paper about my research into Mendoza's work here: Resuscitating a Dead Rabbit

Wayne Clements. July 2020


HOME

";