echo "Player one: Choose (R)ock, (P)aper (S)cissors"
stty -echo
read Pone
case $Pone
in
R) echo "Good Choice! Let's see what Player two chooses.";;
P) echo "Good Choice! Let's see what Player two chooses.";;
S) echo "Good Choice! Let's see what Player two chooses.";;
*) echo "Please choose only R,P or S.";;
esac
echo "Player two: Choose (R)ock, (P)aper (S)cissors"
stty -echo
read Ptwo
case $Ptwo
in
R) echo "Good Choice! ";;
P) echo "Good Choice! ";;
S) echo "Good Choice! ";;
*) echo "Please choose only R,P or S.";;
esac
I need to be able to take both inputs and give it a value 1,2,3,or4 so I can use those values for the possible combination of the outcome. Any suggestions would be appreciated.
Ro
P.S. Does anyone know how to cut and paste between virtual machine and your actual machine?
Last edited by Yogesh Sawant; 04-03-2009 at 02:56 PM..
Reason: added code tags
here's my version of RPS. I tried to get basic functionality for keeping track of the score. Of course, there's still much to improve, but that's your job
Code:
#!/bin/bash
# Load score from files player1.score and player2.score, if they exist.
# Otherwise leave them 0.
p1_number_of_victories=0
p2_number_of_victories=0
if [ -e player1.score -a -e player2.score ]; then
p1_number_of_victories=`cat player1.score`
p2_number_of_victories=`cat player2.score`
fi
function p1_wins() {
p1_number_of_victories=`expr $p1_number_of_victories + 1`
}
function p2_wins() {
p2_number_of_victories=`expr $p2_number_of_victories + 1`
}
abort_game=n
until [ $abort_game = y ]; do
PS3='Choose your action, player 1: '
select action1 in "Rock" "Paper" "Scissors"; do break; done
PS3='Choose your action, player 2: '
select action2 in "Rock" "Paper" "Scissors"; do break; done
case $action1 in
"Rock")
case $action2 in
"Rock") echo "Draw";;
"Paper") echo "Player 2 wins"; p2_wins;;
"Scissors") echo "Player 1 wins"; p1_wins;;
esac
;;
"Paper")
case $action2 in
"Rock") echo "Player 1 wins"; p1_wins;;
"Paper") echo "Draw";;
"Scissors") echo "Player 2 wins"; p2_wins;;
esac
;;
"Scissors")
case $action2 in
"Rock") echo "Player 2 wins"; p2_wins;;
"Paper") echo "Player 1 wins"; p1_wins;;
"Scissors") echo "Draw";;
esac
;;
esac
echo "Do you want to quit the game? [y/N]"
read abort_game
if [ -z "$abort_game" ]; then abort_game=n; fi # -z: input is empty -> ENTER was pressed
done
# end of loop
# Write new score to .score files
echo $p1_number_of_victories > player1.score
echo $p2_number_of_victories > player2.score
# exit gently
exit 0
hello i want to build my career as linux admin.I have completed my Engineering and had one month training on LINUX ADMIN course.I am doing well now in basics.Kindly provide suggetions or advice or books etc etc so that it will enhance my knowledge in linux Redhat. (1 Reply)
Hi
Server configuration is
Processor : xeon 64 bit
Os: centos 5
We are in the process of setting up the Rock Cluster with 5 node.Currently the node are communication with each other
however the disk space is not being shared in the cluster
We would like to know how to used one disk space... (1 Reply)
Hai,
I am trying to install rock4.3 in my Intel core2 quad process, but when i insert kernel cd which is the first step in the installation procedure, it asks for driver disk not found.. insert CD/DVD ROM even after i inserted my CD in my driver.. could anyone help me in solving this problem...... (1 Reply)
I am doing a "research" paper for school and i'm having a hard time finding accurate information. I am supposed to choose three differant versions of unix, give a brief explination of each, tell why there each differant from each other. I have found a ton of web sites but the information is so vast... (1 Reply)