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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.