I wrote this little script one evening a long time ago, for someone who wanted to take pre-printed sheets to work, as it was more stimulating than the work…
#!/bin/bash
# Print out a Boggle board to stdout.
# The 16 dice and their 6 sides each, this creates Dice[n]=
Dice=\
(QBAJOM EFIEYH ODENWS HPSEIN GKYLUE ILUWRG CITAOA BYLTIA \
DZNVEA ODUNKT RHASOM PAECMD GVZTEI OFIRXB REALSC PELUTS)
#
AllDice=" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
# Cut the string that represents the order of the dice in
# the tray 99 time at some random point, then swap the parts
# around. Repeat as needed.
for ((a=1; a <= 100 ; a++))
do
LeftCut=$(($(($(($RANDOM%15))*3))+3))
RightCut=$((LeftCut+3))
LeftEnd=${AllDice:0:LeftCut}
RightEnd=${AllDice:RightCut}
Middle=${AllDice:LeftCut:3}
AllDice="$Middle$LeftEnd$RightEnd"
done
# Roll the Dice to get what side is up.
Count=0
for Each in $AllDice
do
Side=$(($RANDOM%6))
Die=${Dice[Each]:Side:1}
[ $Die == Q ] && echo -n $Die"u " || echo -n $Die" "
[ $((Count%4)) -eq 3 ] && echo
(( Count++ ))
done