please help me to make a knight tour code using c# form

Recommended Answers

All 5 Replies

Are you talking about chess?

yes you are right

What have you done so far?

What knight tour do you want - can you be a bit more specific about the requirements?

okay sorry for the less information of my question

Public Class Form1

    Private Sub button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim n As Integer = TextBox1.Text
        Dim m(n + 4, n + 4) As Integer
        Dim Yaw As Integer = TextBox3.Text
        Dim Xaw As Integer = TextBox2.Text
        Dim Y As Integer = Yaw + 2
        Dim X As Integer = Xaw + 2
        Dim p, ns As Integer
        Dim h As Integer() = {0, 2, 2, -1, -1, -2, -2, -1, 1}
        Dim v As Integer() = {0, -1, 1, 2, 2, 1, -1, -2, -2}
        For i = 1 To n + 4
            For j = 1 To n + 4
                If i < 3 Or i > n + 2 Or j < 3 Or j > n + 2 Then
                    m(i, j) = 1
                Else
                    m(i, j) = 0
                End If
            Next
        Next

        Do
            Yaw = TextBox3.Text
            Xaw = TextBox2.Text
        Loop Until Yaw >= 1 And Yaw <= n And Xaw >= 1 And Xaw <= n
        ns = 1
        p = 1
        m(Y, X) = ns

        Do While p <= 8
            If m(Y + V(p), X + H(p)) = 0 Then
                Y = Y + V(p)
                X = X + H(p)
                ns = ns + 1
                m(Y, X) = ns
                p = 1
            Else
                p = p + 1
            End If
        Loop

        For i As Integer = 3 To n + 2 'baris
            For j As Integer = 3 To n + 2  'kolom
                Dim a As New Label
                a.Text = m(i, j)
                a.Width = 40
                a.Height = 40
                a.Left = ((j - 2) - 1) * 38 + 14
                a.Top = ((i - 2) - 1) * 38 + 127
                Me.Controls.Add(a)
            Next
        Next
    End Sub
End Class

here are my coding but it still in VB Script and i can't translate it into C#
i already run the program in visual studio 2012 and it work, i just need to translate it into c#, but i can't

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.