ASP-based hammer game

Source: Internet
Author: User
<%
'*************************************** ******
'This IS A SIMPLE GAME OF ROCK SCISSORS PAPER
'Feel FREE TO DO WHATEVER YOU LIKE WITH THIS
'Script! -Ian s. CARROLL
'*************************************** ******
'*************************************** ******
'This FUNCTION GENERATES A RANDOM NUMBER
'*************************************** ******
Function computerChooses ()
Dim randomNum
Dim choice
Randomize
RandomNum = int (rnd * 15) + 1
If randomNum = 1 OR randomNum = 3 OR randomNum = 7 OR randomNum = 8 OR randomNum = 15 OR randomNum = 12 Then
Choice = "R"
ElseIf randomNum = 2 OR randomNum = 6 OR randomNum = 11 OR randomNum = 13 Then
Choice = "S"
Else
Choice = "P"
End If
ComputerChooses = choice
End Function
'*************************************** ******
'This FUNCTION SIMPLY DETERMINES THE WINNER
'OF THE GAME
'*************************************** ******
Sub determineWinner (playerChoice, computerChoice)
Const Rock = "R"
Const Scissor = "S"
Const Paper = "P"
Dim tempPlayer, tempComputer
If playerChoice = Rock Then
If computerChoice = Scissor Then
%>
<P> <CENTER>
<BR>
Your ROCK crushed the computer's SCISSORS! "</CENTER>
<%
End If
ElseIf playerChoice = Scissor Then
If computerChoice = Paper Then
%>
<P> <CENTER>
<BR>
Your SCISSORS cut up the computer's PAPER! </CENTER>
<%
End If
ElseIf playerChoice = Paper Then
If computerChoice = Rock Then
%>
<P> <CENTER>
<BR>
Your PAPER stumped the computer's ROCK! </CENTER>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.