*Instructions: Please enter your name, then choose one of PAPER,
SCISSORS OR STONE, then press Continue.
;//THE FIRST PAGE
const html win = MILESTONES NO.2
CONGRATULATION!!! <[name]> COMPUTER HAS A <[compAns]>. & YOU HAVE A <[userAns]>. WIN: <[w]> out of <[c]>
DRAW: <[d]> LOST: <[l]>
PAPER
SCISSORS
STONE
QUIT
;//THE "win" page will appear if the user wins the game
const html lost =
MILESTONES NO.2
SORRY... <[name]> COMPUTER HAS A <[compAns]>. & YOU HAVE A <[userAns]>. WIN: <[w]> out of <[c]>
DRAW: <[d]> LOST: <[l]>
PAPER
SCISSORS
STONE
QUIT
;//THE "lost" page will appear if the user lost the game
const html draw = MILESTONES NO.2
DRAW man !!! <[name]> COMPUTER HAS A <[compAns]>. & YOU HAVE A <[userAns]>. WIN: <[w]> out of <[c]>
DRAW: <[d]> LOST: <[l]>
PAPER
SCISSORS
STONE
QUIT
;//THE "draw" page will appear if the user draws the game
const html finish =
Thank you <[name]> for playing this "great" game
Your score is you win <[w]> out of <[c]>
If you have any comment or question about this game please send
ME an e-mail. Thank you very much.
GO BACK AND PLAY AGAIN!!!!! GO TO MCGILL UNIVERSITY'S HOME PAGE.
; //THE "finish" page will appear if the user press quit in the game
int seed;
int Random()
{
seed = (25173*seed+13849)%65535;
return seed;
}
session Play(){
int ans; //Player's answer
int compAns; //comp's Ans
int count; //Counter for the number of the games
int winNum; //Number of the win games
int drawNum; //Number of the draw games
int lostNum; //Number of the lost games
string name; //Name of the user
string comp; //Computer's decision
string userAns; //user's decision
count = 0;
winNum = 0;
drawNum = 0;
comp="";
name = "";
userAns="";
show welcome receive[name=name, ans=ans];
seed = ans + 1000;
while(ans<4)
{
compAns=(Random()+count*winNum*drawNum)%3+1;
count = count+1;
if(compAns==1) comp="PAPER";
else if(compAns==2) comp="SCISSORS";
else comp="STONE";
if(ans==1) userAns="PAPER";
else if(ans==2) userAns="SCISSORS";
else userAns="STONE";
if(compAns==ans){
drawNum=drawNum+1;
lostNum=count-(winNum+drawNum);
show plug draw[name=name,compAns=comp,userAns=userAns,w=winNum,c=count,d=drawNum,l=lostNum] receive[ans=ans];
}
else if((compAns>ans)||(compAns==1&&ans==3)){
lostNum=count-(winNum+drawNum);
show plug lost [name=name,compAns=comp,userAns=userAns,w=winNum,c=count,d=drawNum,l=lostNum] receive[ans=ans];
}
else{
winNum = winNum + 1;
lostNum=count-(winNum+drawNum);
show plug win [name=name,compAns=comp,userAns=userAns,w=winNum,c=count,d=drawNum,l=lostNum] receive[ans=ans];
}
}
exit plug finish [name=name,w=winNum,c=count];
}
}