markov - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- markov (849B) --- 1 #!/bin/sh 2 3 BASE="$HOME/bin/modules/markov_tech" 4 5 TECH="${BASE}/techs" 6 ADJ="${BASE}/adjectives" 7 COP="${BASE}/copulas" 8 FREQ=2 9 10 ## function 11 rand(){ 12 max="$1" 13 if [ -z "$max" ] || [ "$max" -lt 1 ]; then 14 max=2; 15 fi 16 r=$(echo "$(od -An -N2 -i /dev/urandom) % $max" | bc) 17 echo "$r" 18 } 19 20 21 tech1="$(shuf "${TECH}" | head -1)" 22 tech2="$(shuf "${TECH}" | head -1)" 23 while [ "$tech1" = "$tech2" ]; do 24 tech2="$(shuf "${TECH}" | head -1)" 25 done 26 adj1="$(shuf "${ADJ}" | head -1)" 27 adj2="$(shuf "${ADJ}" | head -1)" 28 while [ "$adj1" = "$adj2" ]; do 29 adj2="$(shuf "${ADJ}" | head -1)" 30 done 31 32 cop="$(shuf "${COP}" | head -1)" 33 res="$adj1 $tech1 $cop $adj2 $tech2" 34 35 a=$(rand $FREQ) 36 while [ "$a" = 1 ]; do 37 ntech="$(shuf "${TECH}" | head -1)" 38 nadj="$(shuf "$ADJ" | head -1)" 39 ncop="$(shuf "$COP" | head -1)" 40 res="$res $ncop $nadj $ntech" 41 a=$(rand $FREQ) 42 done 43 echo "$res"