Lately I've been experimenting with generating pseudo random text. Using two inputs via scripts which use dadadodo https://www.jwz.org/dadadodo/. Interestingly dadadodo is installable on Debian/ubuntu based systems by just doing 'sudo apt install dadadodo' , which makes life a lot easier. The script runs from a terminal and uses a randomiser which chooses between 1 to 3 lines from the top of the file writes those to a holding file then deletes those 3 lines from the top of the source files then adds them back at the bottom ( the script loops until you stop it). Dadadodo randomizes the intermediate file and saves that to a temporary file then we use xdotool to write that to a vim window . Two scripts fight against each other to generate pseudo random Asemic text like this below :
w to begin. Knew how to begin.
Pdh ew eHRoeu sre aolnl yt hiem pHosusieb loen.
t h e H o u s eI nodne
eTdh ew eHRoeu sre aolnl yt hiem pHOosussieb loen: TNhoe
H o u s e o nu steh ei nH owuasiet
ionng tbhye tHoeu slei totnl eT
h e H o u s ed oonr ,t hseo Hsohues ew eont TTHhee
rHeo usee moend Tthoe
H o u s e o nb eT hneo Huosues ei no nw aTIhtei nHGo ubsye tohne
t h e H o u s el iotnt lteh ed oHOor,u sseo osnh et hwee nHto utsoe boen ntoh
e H o u s e
ouns et hien Hwoauistei nogn btyh et heo ulsiet tolne
t h e H o u s ed oonr ,T hseo
HSohues ew eonnt TLhiet tHLoeu sdeo oorn, TShoe
H o u s e o ns hTEh ew eHNotu sIen doene
dt hwe rHEo urseea lolny
t h e H o u s ei mopno stshieb lHEo.u s eI nodneHouse on the House on The House on the House on
The House on the House on The House on The House
on the House on the House on The House on The
House on the House on The House on the House on
the House on the House on The House on the House
on the House on the House on the House on the
House on The House on the House on the House on
The House on the House on The House on The House
on the House on the House on the House on the
House on the House on the House on The House on
The House on the House on t h e H o uBSaec ko nt oT hteh eH otuasbel
eo,n hTahlef Hhooupsien go ns hteh em iHgohuts
e o n T h e fHionuds ea noont THheer
HKoeuys eo no ni tT<h eo rH oauts.e oBna ctkh et oH
o u s e o n the HToaubsle ,o nh
atlhfe hHOopuisneg osnh et hmei gHotu sfei nodn
t h e H o u saen ootnh eTRh ek eHYo uosne
iotn, tohre aHTo ukseey on tihte, HOoru saet
o n t h e H ours ea to!n
the
House on the House on The House on the House on
The House on the House on The House on the House
on the House on the House on
This is an unedited video of the output from the scripts :
Source texts
The two source texts used were Lewis Carrols 'Alice in wonderland' and William Hope Hodgsons 'The house on the borderland' sourced from Project Gutenburg project.
The scripts
There are 3 scripts to run this, I've renamed the source texts as source.txt and contra.txt . The first script is started from the command line and calls the other two scripts in a specific way. They run on an infinite loop until stopped.
starter.sh
lxterminal -e ./test.sh & xterm -e vim & lxterminal -e ./contra.sh
test.sh
#!/bin/bash
#./contra.sh
for (( ; ; ))
do
#rm new.txt
#rm inter.txt
n=$(( $RANDOM % 2 + 1 ))
f=$(( $RANDOM % 2 + 1 ))
#read first n lines of source file
find . -type f -name 'source.txt' | while read filename; do sed -n '1,'$n'p' ${filename} > inter.txt;
#shuffle n lines to end of file and delete those lines from top of file
sed -n '1,'$n'p' ${filename} >> source.txt
#strip $n lines from top starting at line 1 ( to avoid using the same lines over and again)
sed '1,'$n'd' ${filename} > swap.txt
# replace original source with swap
mv swap.txt source.txt
# Do the magic mangling
dadadodo -c $f -p 3 -w 50 inter.txt > new.txt
# type it into a vim window !!
WINDOW_ID=$(xdotool search --name vim)
xdotool windowfocus --sync $WINDOW_ID
xdotool type --file /home/crash-stop/repeater/new.txt
sleep 10
done
done
contra.sh
#!/bin/bash
for (( ; ; ))
do
n=$(( $RANDOM % 3 + 1 ))
f=$(( $RANDOM % 3 + 1 ))
#read first n lines of source file
find . -type f -name 'contra.txt' | while read filename; do sed -n '1,'$n'p' ${filename} > inter2.txt;
#shuffle n lines to end of file and delete those lines from top of file
sed -n '1,'$n'p' ${filename} >> contra.txt
#strip $n lines from top starting at line 1 ( to avoid using the same lines over and again)
sed '1,'$n'd' ${filename} > contraswap.txt
# replace original source with swap
mv contraswap.txt contra.txt
# Do the magic mangling
dadadodo -c $f -p 3 -w 50 inter2.txt > contranew.txt
# type it into a vim window !!
WINDOW_ID=$(xdotool search --name vim)
xdotool windowfocus --sync $WINDOW_ID
xdotool type --file /home/crash-stop/repeater/contranew.txt
sleep 5
done
done