#!/usr/bin/perl -wT # /home/sites/www.in-vacua.com/web/cgi-bin/rabb_web2.pl -w use CGI qw(:all); use strict; ################################################################################## # # # 'rabb_web2.pl' (description: generates versions of the first paragraph # of Little Grey Rabbit - date: early 1960's - stories by Professor Mendoza) # Copyright (C) 2019 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 { ##'The sun [gently] shone over the woods.' my @listnames = ('The clouds', 'The sun', 'The breeze', 'The sky'); my $thing = $listnames[int(rand(@listnames))]; #print $thing; 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))]; #print $action2; ################################### 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) # ok { push @adverbchoice2, ($action2) x $adverb2{$action2}; } my $what = $adverbchoice2[int(rand(@adverbchoice2))]; #print $what; ######################## 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))]; #print $newword2; ############################ # The sun [gently] shone over the woods. my @p1s1 =($thing,' ',$action2, ' ', $what,' ', $newword2,'. '); my $whatnot = join " ", @p1s1; $whatnot =~ s/\s+/ /g; $whatnot =~ s/\s+\./\./g; print $whatnot; } ######################################### SUB 2 ########################################### sub p1s2 { ## Over the woods gently drifted the clouds which 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 ################################################################################# # # *the clouds* which calmly floated all afternoon moved across the fields sub p1s3 { my @listnames = ('the clouds', 'the sun', 'the breeze', 'the sky'); my $thing = $listnames[int(rand(@listnames))]; #print $thing; # the clouds, which calmly *floated* all afternoon, moved across the fields 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))]; #print $action2; ################################### # the clouds which *calmly* floated all afternoon moved across the fields 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))]; ############################# # # then the clouds which calmly floated *all afternoon* moved across the fields 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; ##################################################################################################### # # then the clouds which calmly floated all afternoon *moved* across the fields 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))]; #print $action3; ########################################################################################################### # # then the clouds which calmly floated all afternoon moved *across the fields* 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))]; #print $newword3; ############################ # # $thing [which] $newword $action2 $newword2 $action3 $newword3 # # the clouds, which calmly floated all afternoon, moved across the fields 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; } 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(); 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 examples are reproduced. This is the first paragraph:

'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.



My program emulates the construction of this paragraph.

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.

Wayne Clements. June 2019


HOME

";