Генератор прози
Отже, ідея нині така: генератор речень нічого не вибирає, він розставляє слова по ничках. Звертається в один-єдиний wordhash, бере, що для нього там покладено – і розставляє. Підмет на місце підмета, присудок на місце присудка, крапку на місце крапки. Вибір робиться в генераторі сюжета.
Сюжет є ланцюжок дій, логічно пов’язаних + почуття персонажів. Пресловуті арки тут. Дія є подолання перепони.
Сюжет є ланцюжок перепон. Obstacle race.

Plot Generator => %wordhash => SyntaxGen (simply word placer. No choice for it.)
Plot: chain of logically connected actions + character feelings.
Action: overcoming an obstacle.

Tasks: build the emotional cycle for ' John'. [There's only one unspecified type of event, which is 'Something'. "Somethings" happen. John's, apparently, a manic-depressive. His fgs aren't connected to the plot event semantics. ]
alternate narration and dialog. ['Cate' is in for conversation. Her fgs are random-picked. ]

Output xamples:
Something happened. John was happy.
- Are you happy, - asked Cate.
- Oh,yes! I am happy, - said John.
Something happened. John was bored.

Something happened. John was sad.
- Are you bored, - asked Cate.
- Not at all! I am sad, - said John.
> Something happened. John was happy.

Something happened. John was bored.
- Are you happy, - asked Cate.
- Not at all! I am bored, - said John. Something happened. John was sad.

Something happened. John was happy.
- Are you happy, - asked Cate.
- Oh,yes! I am happy, - said John.
Something happened. John was bored.

Something happened. John was sad.
- Are you happy, - asked Cate.
- Not at all! I am sad, - said John.
>

Something happened. John was happy.
- Are you happy, - asked Cate.
- Oh,yes! I am happy, - said John.
Something happened. John was bored.
- Are you bored, - asked Cate.
- Oh,yes! I am bored, - said John.
Something happened. John was sad.
- Are you happy, - asked Cate.
- Not at all! I am sad, - said John.
> - Ah! - said Cate. - And I am happy if yyou want to know.
Something happened. John was happy.
Something happened. John was bored.
Something happened. John was sad.
- Are you sad, - asked Cate.
- Oh,yes! I am sad, - said John.
Something happened. John was happy.
Something happened. John was bored.
Something happened. John was sad.


(Final Version. The code is below)

Something happened. John was happy.
- Are you happy, - asked Cate.
- Oh,yes! I am happy, - said John.
- Ah! - said Cate. - And I am happy too,, if you want to know.
Something happened. John was bored.
Something happened. John was sad.
Something happened. John was happy.
Something happened. John was bored.
- Are you happy, - asked Cate.
- Not at all! I am bored, - said John. Something happened. John was sad.
Something happened. John was happy.
- Are you sad, - asked Cate.
- Not at all! I am happy, - said John. Something happened. John was bored.
Something happened. John was sad.
- Are you happy, - asked Cate.
- Not at all! I am sad, - said John.
> - Ah! - said Cate. - And I am happy, if you want to know.



The code
#!/usr/bin/perl
#use warnings;

&data;

foreach $cycle (0..8){
&kolo;
&randa;
if ($i == 0){&talk;} #don't ALWAYS talk
}


sub data{
@feel = qw(happy bored sad); # Feeling values
@namez = qw(John Cate);
$hr1 = $namez[0];
$hr2 = $namez[1];
$sth = 'Something happened. ';
%curr = ('c_fg', "-1"); # Hash holding the current feeling value
}

sub kolo {
&currfeel;
print $sth, $hr1, ' was ', "$fg. \n";
}

sub currfeel{
$y = $curr{c_fg};
if ($y < y =" 0;"> 2){$y = 0; $curr{c_fg} = 0;}
$fg = $feel[$y];
$curr{c_fg} += 1;
}

sub talk{
&randa;
print ' - Are you ', $feel[$i], ', - asked ', $hr2, ".\n ";
if ($feel[$i] eq $fg) {print ' - Oh,yes! I am ', $feel[$i], ', - said ', $hr1, ".\n "; }
if ($feel[$i] ne $fg) {print ' - Not at all! I am ', $fg, ', - said ', $hr1, ".\n "; }

&randa;
if ($i == 0) {
eval "&randa"; #RND-generate feeling for Cate
print ' - Ah! - said ', $hr2, '. - And I am ', $feel[$i];
eval "&too";
print ", if you want to know.\n ";
}
}

sub too {
if ($feel[$i] eq $fg){print ' too';} # If John and Cate feel the same
if ($feel[$i] ne $fg){print '';} # If not print an empty
}

sub randa {$i = int( rand(3) );
}