read -p "是否开始游戏(y/n)" a;
while [ $a == y ] ;do
read -p "
* * * * * * *
* 石头(0) *
* 剪刀(1) *
* 布(2) *
* 退出(3) *
* * * * * * *
" b;
c=`echo $[$RANDOM%3]`;
if [ $b == $c ] ;then
echo "玩家:$b";
echo "电脑:$c";
echo "平局!";
elif [ $b == 3 ] ;then
echo "退出游戏!";
else
if [ $b == 1 -a $c == 2 ] ;then
echo "玩家:$b";
echo "电脑:$c";
echo "玩家:胜!";
elif [ $b == 0 -a $c == 1 ] ;then
echo "玩家:$b";
echo "电脑:$c";
echo "玩家:胜!";
elif [ $b == 2 -a $c == 0 ] ;then
echo "玩家:$b";
echo "电脑:$c";
echo "玩家:胜!";
else
echo "玩家:$b";
echo "电脑:$c";
echo "电脑:胜!";
fi
fi
if [ $b == 3 ] ;then
break;
fi
done
刚刚接触写的不好0.0