AI智能
改变未来

Linux:写一个与电脑玩石头剪刀布的脚本


人机石头剪刀布

#!/bin/bashecho \"Choice the numbers!\"read -p \"Made your choice rock:1  paper:2  scissors:3 : \" Choice#echo $Choiceif [[ $Choice =~ [123] ]];thencomputer=$[ $RANDOM%3+1 ]#    echo $computerif [ $Choice -ne $computer ];thenif [ $Choice -eq 1 ];then[ $computer -eq 3 ] && echo \"Computer is scissors. YOU WIN!\" && exit || echo \"Computer is paper. YOU LOSE!\" && exitfiif [ $Choice -eq 2 ];then[ $computer -eq 1 ] && echo \"Computer is rock. YOU WIN!\" && exit || echo \"Computer is scissors. YOU LOSE!\" && exitfiif [ $Choice -eq 3 ];then[ $computer -eq 2 ] && echo \"Computer is paper. YOU WIN!\" && exit || echo \"Computer is rock. YOU LOSE!\" && exitfifiecho \"Tie!\"fiecho \"You gotta follow my tips like rock:1  paper:2  scissors:3.\"

玩起来!

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » Linux:写一个与电脑玩石头剪刀布的脚本