Subscribe to sudokuking's Blog        RSS Feed
-----

Deal Or No Deal

Icon 3 Comments
Hey every1. I'm making a new game called Deal or no deal(American verison) in VISUAL BASIC 10. The code I already have is :
Public Class Form1
    Dim a As Integer
    Dim CaseNumber(25) As Integer
    Dim StartArray As Integer
    Dim MyCase As Integer
    Dim PickCase As Integer
    Dim bankersoffer As Double
    Dim numberofcasesleft As Integer
    Dim expectedvalue As Double
    Dim maximumvalueleft As Double
    Public Function RandomNumber(ByVal MaxNumber As Integer, Optional ByVal MinNumber As Integer = 0) As Integer
        'Initialize random number gererator
        Dim r As New Random(System.DateTime.Now.Millisecond)
        'If passed incorrect arguements, swap them
        'can also throw exception or return 0
        If MinNumber > MaxNumber Then
            Dim t As Integer = MinNumber
            MinNumber = MaxNumber
            MaxNumber = t
        End If
        a = r.Next(MinNumber, MaxNumber)
        Return MinNumber
    End Function
    Private Sub btnChoose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChoose.Click
        Dim count As Integer = 0
        Dim countadd As Integer = 0
        RandomNumber(1, 27)
        count = 0
        Do While count <= 25
            If CaseNumber(count) = a Or MyCase = a Then
                RandomNumber(1, 27)
                count = 0
            ElseIf count = 25 And CaseNumber(count) = 0 Then
                countadd = 0
                Do While countadd <= 25
                    If CaseNumber(countadd) = 0 Then
                        CaseNumber(countadd) = a
                        countadd = 25
                    End If
                    countadd = countadd + 1
                Loop
            End If
            count = count + 1
        Loop
        txtCase.Text = a
        PickCase = PickCase + 1
        numberofcasesleft = 26
        maximumvalueleft = 3418416.01
        Select Case a
            Case 1
                lblCase1.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 2
                lblCase2.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 3
                lblCase3.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 4
                lblCase4.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 5
                lblCase5.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 6
                lblCase6.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 7
                lblCase7.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 8
                lblCase8.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 9
                lblCase9.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 10
                LblCase10.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 11
                lblCase11.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 12
                lblCase12.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 13
                lblCase13.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 14
                lblCase14.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 15
                lblCase15.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 16
                lblCase16.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 17
                lblCase17.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 18
                lblCase18.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 19
                lblCase19.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 20
                lblCase20.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 21
                lblCase21.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 22
                lblCase22.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 23
                lblCase23.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 24
                lblCase24.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 25
                lblCase25.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
            Case 26
                lblCase26.ForeColor = Color.Red
                numberofcasesleft -= 1
                bankersoffer = 12275.3 + (0.748 * expectedvalue) + (-2714.74 * numberofcasesleft) + (-0.04 * maximumvalueleft) + (0.0000006986 * (expectedvalue * expectedvalue)) + (32.623 * (numberofcasesleft * numberofcasesleft))
        End Select
        Select Case PickCase
            Case 6
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
            Case 11
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
            Case 15
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
            Case 18
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
            Case 20
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
            Case 21
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
            Case 22
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
            Case 23
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
            Case 24
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
            Case 25
                MsgBox("The Banker's Offer is " & bankersoffer & "!")
                Form2.Visible = True
                btnChoose.Enabled = False
        End Select
    End Sub
    Private Sub btnChooseMyCase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChooseMyCase.Click
        RandomNumber(27, 1)
        txtMyCase.Text = a
        CaseNumber(0) = a
        MyCase = a
        Select Case a
            Case 1
                lblCase1.ForeColor = Color.Green
            Case 2
                lblCase2.ForeColor = Color.Green
            Case 3
                lblCase3.ForeColor = Color.Green
            Case 4
                lblCase4.ForeColor = Color.Green
            Case 5
                lblCase5.ForeColor = Color.Green
            Case 6
                lblCase6.ForeColor = Color.Green
            Case 7
                lblCase7.ForeColor = Color.Green
            Case 8
                lblCase8.ForeColor = Color.Green
            Case 9
                lblCase9.ForeColor = Color.Green
            Case 10
                LblCase10.ForeColor = Color.Green
            Case 11
                lblCase11.ForeColor = Color.Green
            Case 12
                lblCase12.ForeColor = Color.Green
            Case 13
                lblCase13.ForeColor = Color.Green
            Case 14
                lblCase14.ForeColor = Color.Green
            Case 15
                lblCase15.ForeColor = Color.Green
            Case 16
                lblCase16.ForeColor = Color.Green
            Case 17
                lblCase17.ForeColor = Color.Green
            Case 18
                lblCase18.ForeColor = Color.Green
            Case 19
                lblCase19.ForeColor = Color.Green
            Case 20
                lblCase20.ForeColor = Color.Green
            Case 21
                lblCase21.ForeColor = Color.Green
            Case 22
                lblCase22.ForeColor = Color.Green
            Case 23
                lblCase23.ForeColor = Color.Green
            Case 24
                lblCase24.ForeColor = Color.Green
            Case 25
                lblCase25.ForeColor = Color.Green
            Case 26
                lblCase26.ForeColor = Color.Green
        End Select
        btnChooseMyCase.Enabled = False
        btnChoose.Enabled = True
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        btnChoose.Enabled = False
    End Sub
    Sub Reload()
        btnChoose.Enabled = False
        btnChooseMyCase.Enabled = True
        PickCase = 0
        txtCase.Text = ""
        txtMyCase.Text = ""
        For i = 0 To 25
            CaseNumber(i) = 0
        Next
        lblCase1.ForeColor = Color.Black
        lblCase2.ForeColor = Color.Black
        lblCase3.ForeColor = Color.Black
        lblCase4.ForeColor = Color.Black
        lblCase5.ForeColor = Color.Black
        lblCase6.ForeColor = Color.Black
        lblCase7.ForeColor = Color.Black
        lblCase8.ForeColor = Color.Black
        lblCase9.ForeColor = Color.Black
        LblCase10.ForeColor = Color.Black
        lblCase11.ForeColor = Color.Black
        lblCase12.ForeColor = Color.Black
        lblCase13.ForeColor = Color.Black
        lblCase14.ForeColor = Color.Black
        lblCase15.ForeColor = Color.Black
        lblCase16.ForeColor = Color.Black
        lblCase17.ForeColor = Color.Black
        lblCase18.ForeColor = Color.Black
        lblCase19.ForeColor = Color.Black
        lblCase20.ForeColor = Color.Black
        lblCase21.ForeColor = Color.Black
        lblCase22.ForeColor = Color.Black
        lblCase23.ForeColor = Color.Black
        lblCase24.ForeColor = Color.Black
        lblCase25.ForeColor = Color.Black
        lblCase26.ForeColor = Color.Black
    End Sub
End Class

That was for the 1st form.
this is my 2nd form :
Public Class Form2
    Dim a As Integer
    Dim Final As Integer
    Private Sub BtnNoDeal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNoDeal.Click
        Final = Final + 1
        If Final = 9 Then
            RandomNumber(1, 11)
            If a = 2 Or a = 4 Or a = 8 Or a = 10 Then
                MsgBox("The computer has randomly chosen to keep your case!")
            ElseIf a = 1 Or a = 3 Or a = 5 Or a = 7 Or a = 9 Then
                MsgBox("The computer has randomly chosen to switch cases!")
            End If
            Form1.Reload()
            Final = 0
        End If
        Form1.btnChoose.Enabled = True
        Me.Visible = False
    End Sub
    Private Sub BtnDeal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDeal.Click
        Form1.Reload()
        Me.Close()
    End Sub
Public Function RandomNumber(ByVal MaxNumber As Integer, Optional ByVal MinNumber As Integer = 0) As Integer
        'Initialize random number gererator
        Dim r As New Random(System.DateTime.Now.Millisecond)
        'If passed incorrect arguements, swap them
        'can also throw exception or return 0
        If MinNumber > MaxNumber Then
            Dim t As Integer = MinNumber
            MinNumber = MaxNumber
            MaxNumber = t
        End If
        a = r.Next(MinNumber, MaxNumber)
        Return MinNumber
    End Function
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form1.btnChoose.Enabled = False
    End Sub
End Class

Can some1 help me with the dealer's offer. i don't know how to start on it or how to code it......
Another thing I need help with is the random randomizing of the all 26 values ing the LABELS.

3 Comments On This Entry

Page 1 of 1

sudokuking Icon

01 June 2012 - 08:04 AM
Any Help will be appreciated
0

AdamSpeight2008 Icon

01 June 2012 - 10:34 AM
Can some of the code you've written, be re-factored into their own methods? As I see lots of repetition.
0

sudokuking Icon

05 June 2012 - 05:07 AM
Can some1 tell me the algorithm for the dealer's offer for deal or no deal
0
Page 1 of 1

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

October 2014

S M T W T F S
    1 234
567891011
12131415161718
19202122232425
262728293031 

Tags

    Recent Entries

    Recent Comments

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)

    Categories