Jump to content

Search the Community

Showing results for tags 'paper scissors rock'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. This is a function I came up with to determine the outcome of selecting Paper, Scissors or Rock. See below for more details. Function and Example: (Classic game) Example() Func Example() Local $sComputer, $sOutcome = '', $sUser = '' For $i = 0 To 2 For $j = 0 To 2 Switch _RockPaperScissors($i, $j, $sUser, $sComputer) Case -1 ; Draw $sOutcome = 'Draw' Case 0 ; Lose $sOutcome = 'Lost' Case Else ; Win $sOutcome = 'Won' EndSwitch ConsoleWrite('The user selected ' & $sUser & ' and the PC chose ' & $sComputer & ', the outcome was: ' & $sOutcome & @CRLF) Next Next EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _RockPaperScissors ; Description ...: Determine the outcome between the classic game of 'Paper, Scissors or Rock?' ; Syntax ........: _RockPaperScissors($iUserChoice, $iComputerChoice, Byref $sUserChoice, Byref $sComputerChoice) ; Parameters ....: $iUserChoice - An integer value of the item for the user (see remarks.) ; $iComputerChoice - An integer value of the item for the computer (see remarks.) ; $sUserChoice - [in/out] A variable to store the string representation of the user's choice. ; $sComputerChoice - [in/out] A variable to store the string representation of the computer's choice. ; Return values .: |-1 - Draw (both choices resulted in a draw.) ; |0 - Lose (the user's choice lost.) ; |1 - Win (the user's choice won.) ; Author ........: guinness ; Modified ......: Malkey - Idea for ComputerChoice + 1. ; Remarks .......: |0 - Rock ; |1 - Paper ; |2 - Scissors ; Example .......: Yes ; =============================================================================================================================== Func _RockPaperScissors($iUserChoice, $iComputerChoice, ByRef $sUserChoice, ByRef $sComputerChoice) Local $aChoice[3][4] = [['Rock', -1, 0, 1],['Paper', 1, -1, 0],['Scissors', 0, 1, -1]] If $iUserChoice = Default Then $iUserChoice = 0 If $iComputerChoice = Default Then $iComputerChoice = Random(0, 2, 1) $sUserChoice = $aChoice[$iUserChoice][0] $sComputerChoice = $aChoice[$iComputerChoice][0] Return $aChoice[$iUserChoice][$iComputerChoice + 1] EndFunc ;==>_RockPaperScissorsFunction and Example: (New variation with Spock and Lizard) Example() Func Example() Local $sComputer, $sOutcome = '', $sUser = '' For $i = 0 To 4 For $j = 0 To 4 Switch _RockPaperScissorsLizardSpock($i, $j, $sUser, $sComputer) Case -1 ; Draw $sOutcome = 'Draw' Case 0 ; Lose $sOutcome = 'Lost' Case Else ; Win $sOutcome = 'Won' EndSwitch ConsoleWrite('The user selected ' & $sUser & ' and the PC chose ' & $sComputer & ', the outcome was: ' & $sOutcome & @CRLF) Next Next EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _RockPaperScissorsLizardSpock ; Description ...: Determine the outcome between the unique game of 'Rock, Paper, Scissors, Lizard or Spock?' ; Syntax ........: _RockPaperScissorsLizardSpock($iUserChoice, $iComputerChoice, Byref $sUserChoice, Byref $sComputerChoice) ; Parameters ....: $iUserChoice - An integer value of the item for the user (see remarks.) ; $iComputerChoice - An integer value of the item for the computer (see remarks.) ; $sUserChoice - [in/out] A variable to store the string representation of the user's choice. ; $sComputerChoice - [in/out] A variable to store the string representation of the computer's choice. ; Return values .: |-1 - Draw (both choices resulted in a draw.) ; |0 - Lose (the user's choice lost.) ; |1 - Win (the user's choice won.) ; Author ........: guinness ; Modified ......: Malkey - Idea for ComputerChoice + 1. ; Remarks .......: |0 - Rock ; |1 - Paper ; |2 - Scissors ; |3 - Lizard ; |4 - Spock ; Example .......: Yes ; =============================================================================================================================== Func _RockPaperScissorsLizardSpock($iUserChoice, $iComputerChoice, ByRef $sUserChoice, ByRef $sComputerChoice) Local $aChoice[5][6] = [['Rock', -1, 0, 1, 1, 0],['Paper', 1, -1, 0, 0, 1],['Scissors', 0, 1, -1, 1, 0],['Lizard', 0, 1, 0, -1, 1],['Spock', 1, 0, 1, 0, -1]] If $iUserChoice = Default Then $iUserChoice = 0 If $iComputerChoice = Default Then $iComputerChoice = Random(0, 4, 1) $sUserChoice = $aChoice[$iUserChoice][0] $sComputerChoice = $aChoice[$iComputerChoice][0] Return $aChoice[$iUserChoice][$iComputerChoice + 1] EndFunc ;==>_RockPaperScissorsLizardSpock
×
×
  • Create New...