Question problem with array

dentfree

New member
Joined
Feb 28, 2012
Messages
3
Programming Experience
Beginner
I creat a minstermind. For check if color is right I creat 4 arrays (proposal, True, false, solution). But, if I have 2 same colors, the verication is not true, if i got 4 colors misplaced, the program show just 3 colors misplaced.
My code is :

VB.NET:
    Private Function VerificationColor()
        Dim i As Integer

        'Initialisation arrays
        For t = 0 To NumberHide - 1
            ArrayTrue(t) = 0
        Next
        For t = 0 To NumberHide - 1
            ArrayFalse(t) = 0
        Next

        'verification color
        For i = 0 To NumberHide - 1
            If Arrayproposal(i) = ArraySolution(i) Then ArrayTrue(i) = 1
        Next

        For o As Integer = 0 To NumberHide - 1
            If ArrayTrue(o) = 0 Then
                For j As Integer = 0 To NumberHide - 1
                    If ArrayTrue(j) = 0 And Arrayproposal(o) = ArraySolution(j) Then
                        ArrayFalse(j) = 2
                        Exit For
                    End If
                Next
            End If
        Next

        Dim result As String
        result = ""
        star = 0

        For t = 0 To NumberHide - 1
            If ArrayTrue(t) = 1 Then result = result + "*" : star = star + 1
        Next
        For t = 0 To NumberHide - 1
            If ArrayFalse(t) = 2 Then result = result + "°"
        Next


        Return result
    End Function
 
Last edited:
Back
Top