• Tip Jar

CLI Day 2015

For CLI Day this year, I have put together a collection of one-line games. You can copy and paste these games directly into your terminal and play them, or you can put them into a file, one per file, and run them that way as well. These were a lot of fun to make, and even more fun to play. If you follow @storm@social.stormdragon.tk you have seen a few previews. Here are the games. I hope you enjoy them as much as I do. If you have any to contribute please leave them in the comments.

#Match the letter
s=99;while [ : ];do t=$(shuf -n1 -e {a..z});read -t0.$s -n1 -p " $t " p;if [ "$t" != "$p" ];then play -nV0 synth pi fade q 0 1 0.5;break;else play -nV0 synth .05 tri C8:C3 norm -7;fi;((s--));done
#guess 1 to 10
read -p"Guess from 1 to 10 " num;if [ $num -eq $(seq 10|shuf -n1) ]; then echo "Yay!";else echo "Boo!";fi
#order the numbers 1-9 type the number to reverse the string from that number to the right
c=0;n=$(shuf -i 1-9|tr -d "\n");while [ $n -ne 123456789 ]; do read -n1 -p$n i;l=${n%$i*};l=${#l};a=${n:0:$l};b=$(echo ${n:$l}|rev);n=$a$b;echo;((c++));done;echo "$n $c tries"
#spelling game with changable list
l=(champagne neighbor tortoise);clear;s="espeak -v en-us -a 200";for i in ${l[@]};do $s $i;read w;if [ "$w" = "$i" ];then $s "Got it!";else c=0;while [ $c -lt ${#i} ];do $s ${i:$c:1};((c++));done;fi;done &> /dev/null
#Simple configurable math game, change o for different types, set n min and x max numbers used.
n=0;x=10;o=+;m=0;r=0;s=5;t=0;a=-;while [ "${a^}" != "Q" ];do p="$(shuf -n1 -i$n-$x)$o$(shuf -n1 -i$n-$x)";read -t$s -p "$p " a;if [ $a -eq $(($p)) ] ; then echo "Yay!";((r++));s=$(echo "scale=2;$s-0.05" | bc);else echo "Wrong: $(($p))";((m++));fi 2> /dev/null;((t++));done;echo -e "\n$r right and $(($m-1)) missed of $(($t-1)) total."
#Pig dice game. any letter to roll, space or enter to bank.
c=0;p=0;s=0;t=$(shuf -n1 -e c p);while [ $c -lt 100 -a $p -lt 100 ];do if [ $t = c ];then a=$(shuf -n1 -i0-6);case $a in 0)c=$(($c+$s));s=0;t=p;echo "CPU banked $c.";;1)echo "CPU Pigged\!";s=0;t=p;;*)s=$(($s+$a));echo "CPU $s : $c";esac;else read -n1 -p "? " a;if [ -z $a ];then t=c;p=$(($s+$p));echo "You banked $p.";s=0;else a=$(shuf -n1 -i1-6);if [ $a -eq 1 ];then s=0;t=c;echo "You Pigged\!";else s=$(($s+$a));echo "You $s : $p";fi;fi;fi;done;echo "CPU $c : You $p"
#Shoot down the eroflcopter you hear when sound is centered. Random speeds.
h=0;n=1;s=20;while [ $n -eq 1 ];do x=9;y=0;while [ $x -gt 0 ];do espeak --stdout [[schXh | play -qV0 - norm remix v0.$x v0.$y&read -st0.$s -n1 p;if [ -n "$p" ]; then if [ $x -eq 5 -a $y -eq 4 -o $x -eq 4 -a $y -eq 5 ];then x=9;y=0;play -nqV0 synth pi fade h 0 1 1 pad 0 1 reverb overdrive riaa speed 32 repeat 2;play -nqV0 synth pi fade h 0 1 1 norm -18 pad 0 1 reverb overdrive riaa;((h++));s=$(seq 10 20|shuf -n1);else n=0;fi;fi;((x--));((y++));done;done;echo "You shot down $h eroflcopters."
#Talking CLIcat (pitch shifter).
e="norm pitch 1000";echo "Hold down control+c to exit.";f=$(mktemp -u);while :;do rec -q $f.wav silence 0 1 0:00:00.5 25% && play -qV0 $f.wav $e;done
# Small polyphonic music synthesizer.
n=CDEFGAB;l=asdfghj;while read -n1 k;do x=$(tr $l $n< <<$k);play -qn synth pl ${x}3 fade 0 .7 & >/dev/null;done

Bookmark the permalink.

One Comment

Comments are closed

  • Tip Jar