人机石头剪刀布
#!/bin/bash
echo "Choice the numbers!"
read -p "Made your choice rock:1 paper:2 scissors:3 : " Choice
#echo $Choice
if [[ $Choice =~ [123] ]];
then
computer=$[ $RANDOM%3+1 ]
# echo $computer
if [ $Choice -ne $computer ];
then
if [ $Choice -eq 1 ];
then
[ $computer -eq 3 ] && echo "Computer is scissors. YOU WIN!" && exit || echo "Computer is paper. YOU LOSE!" && exit
fi
if [ $Choice -eq 2 ];
then
[ $computer -eq 1 ] && echo "Computer is rock. YOU WIN!" && exit || echo "Computer is scissors. YOU LOSE!" && exit
fi
if [ $Choice -eq 3 ];
then
[ $computer -eq 2 ] && echo "Computer is paper. YOU WIN!" && exit || echo "Computer is rock. YOU LOSE!" && exit
fi
fi
echo "Tie!"
fi
echo "You gotta follow my tips like rock:1 paper:2 scissors:3."
玩起来!