Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9021717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:19:20+00:00 2026-06-16T05:19:20+00:00

Im head is spinning right now, and its probably because I’ve missed out some

  • 0

Im head is spinning right now, and its probably because I’ve missed out some basic logic.

I have a ‘Rock, Paper, scissor’ program in VB.NET which gives the correct results for each individual game/round. The problem that I have is when trying to determine the result for a MATCH which can also be a ‘Win, Loose, Draw’. Matches are Best-of-3 (first to 2) and Best-of-5 (first to 3). As the outcome of the match can be a draw, this has various combinations/permutations such as:

  1. W, L, D
  2. L, W, D
  3. L, D, W
  4. D, L, W
  5. W, D, L, …. etc…

I have the following code so far:

    Public Class GameForm
    Private humanScore As Integer = 0
    Private compScore As Integer = 0
    Private drawScore As Integer = 0
    Private totalGames As Integer = 0
    Private totalGamesForWin As Integer = 0
    Private totalGamesPlayed As Integer = 0
    Private player1 = New PlayerHumanPlayer()
    Private player2 = New PlayerComputerRandom()


    Private Sub GameForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If GameTypeForm.cmboMatchDuration.SelectedItem = 0 Then
            totalGames = 3
            totalGamesForWin = 2
            lblMatchInfor.Text = GlobalVariables.MatchTypeBestOf3Message
        ElseIf (GameTypeForm.cmboMatchDuration.SelectedItem = 1) Then
            totalGames = 5
            totalGamesForWin = 3
            lblMatchInfor.Text = GlobalVariables.MatchTypeBestOf5Message
        End If

    End Sub

    Private Sub btnRock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRock.Click
        findGameWinner("HumanPlayer", "Rock", "RandomComputer")
    End Sub

    Private Sub btnPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPaper.Click
        findGameWinner("HumanPlayer", "Paper", "RandomComputer")
    End Sub


    Private Sub btnScissors_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnScissors.Click
        findGameWinner("HumanPlayer", "Scissors", "RandomComputer")
    End Sub

    Public Sub findGameWinner(ByVal p1name As String, ByVal p1WeaponSelected As String, ByVal p2Name As String)

        player1.Name = p1name
        player1.pickWeapon(p1WeaponSelected)  ' Should I be using the Rock Class???

        player2.Name = p2Name
        player2.pickWeapon()

        Dim winner As Integer = player1.getWeapon().compareTo(player2.getWeapon())

        Select Case winner
            Case 1
                updateScores(True, False)
                findMatchWinner()
            Case -1
                updateScores(False, True)
                findMatchWinner()
            Case 0
                updateScores(False, False)
                findMatchWinner()
        End Select
    End Sub

    Public Function updateScores(ByVal humanWon As Boolean, ByVal compWon As Boolean) As Integer

        If humanWon = True Then
            humanScore = humanScore + 1

            'Update Human labels
            lblPlayerScore.Text = humanScore.ToString()
            'txtCompChoice.Text = txtCompChoice.Text + Environment.NewLine + Type.GetType(player2.pWeapon.ToString()).ToString()
            txtCompChoice.Text = txtCompChoice.Text + Environment.NewLine + player2.pWeapon.ToString()
            txtGameStatus.Text = txtGameStatus.Text + Environment.NewLine + player1.Name() + " wins!"

        ElseIf compWon = True Then
            compScore = compScore + 1

            'Update Computer labels
            lblCompScore.Text = compScore.ToString()
            'txtCompChoice.Text = txtCompChoice.Text + Environment.NewLine + Type.GetType(player2.pWeapon.ToString()).ToString() 
            txtCompChoice.Text = txtCompChoice.Text + Environment.NewLine + player2.pWeapon.ToString()
            txtGameStatus.Text = txtGameStatus.Text + Environment.NewLine + player2.Name() + " wins!"

        Else
            drawScore = drawScore + 1

            'Update Draw labels
            lblDrawGame.Text = drawScore.ToString()
            'txtCompChoice.Text = txtCompChoice.Text + Environment.NewLine + Type.GetType(player2.pWeapon.ToString()).ToString()
            txtCompChoice.Text = txtCompChoice.Text + Environment.NewLine + player2.pWeapon.ToString()
            txtGameStatus.Text = txtGameStatus.Text + Environment.NewLine + "Draw!"

        End If

        totalGamesPlayed = totalGamesPlayed + 1

        Return totalGamesPlayed
    End Function


    Public Function findMatchWinner() As String

        If totalGamesPlayed <> totalGames Then
            If humanScore = totalGamesForWin Then
                lblMatchInfor.Text = GlobalVariables.HumanMacthWinMessage
                clearForm()
            ElseIf compScore = totalGamesForWin Then
                lblMatchInfor.Text = GlobalVariables.CompMacthWinMessage
                clearForm()
            ElseIf totalGamesPlayed = totalGames - 1 Then
                lblMatchInfor.Text = GlobalVariables.DeciderGameMessage
            End If
        ElseIf humanScore = totalGamesForWin Then
            lblMatchInfor.Text = GlobalVariables.HumanMacthWinMessage
            clearForm()
        ElseIf compScore = totalGamesForWin Then
            lblMatchInfor.Text = GlobalVariables.CompMacthWinMessage
            clearForm()
        ElseIf (drawScore = totalGamesPlayed) Then
            lblMatchInfor.Text = GlobalVariables.DrawMacthWinMessage
            clearForm()
        End If

        Return "Human OR Computer"
    End Function

    Public Sub clearForm()

    End Sub

End Class

I thought I was doing good until I remembered that I completely forgot about the Draw/Tie. Since then my head has been looping so could someone kindly shed some light on how to get findMatchWinner() function working properly?

Any help would be greatly appreciated.

Manys thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:19:21+00:00Added an answer on June 16, 2026 at 5:19 am

    I would suggest that instead of checking how many wins there were for one player and seeing if it was the amount expected for the amount of rounds played you could just record the wins for both payers and compare them at the end.

    If Player A > Player B then Player A wins, if they are the same it is a draw. Also, remember that a game of 3 rounds does not need 2 wins for a winner as Player A could win once and then all other games could be Draws.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm banging my head for some hours now. I have a select option that
I'm not sure why my head is spinning right now - long day for
I am just now starting to use version control and my head is spinning!
I'm looking for a decent, elegant method of calculating this simple logic. Right now
My head is spinning trying to figure out the SQL query I need to
My head is about to explode with this logic, can anyone help? Class A
I have to insert some data into a MySQL table. The data will be
I've spent a couple of hours looking at this and my head's spinning. Can
My head is getting bad trying to find a solution for this assignment because
I read this book: Head First Object-Oriented Analysis and Design Now i am looking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.