|
-
Jul 28th, 2010, 05:19 PM
#3
Thread Starter
New Member
Re: find line sequence
no.. there are 4 kinds of hexagons, each with different lines inside them, in the begining, the computer randomly spreads some of each around, and we have to play with them until this line is form.
through several and several loops, i have been able to do this, but it is my thinking that the code is really rubbish...
here it is what i have done:
[code]
Sub find_consecutive_lines2()
update_lines_list()
Dim curren_line_streak As New List(Of line)
Dim current_formal_streak As New line_streak
Dim wanted_point As Point
Dim complete_streaks As New List(Of line_streak)
Dim found_a_line As Boolean
For i = 0 To all_lines.Count - 1
current_formal_streak = New line_streak
curren_line_streak.Clear()
If is_point_on_edge(all_lines(i).point1) Or is_point_on_edge(all_lines(i).point2) Then
If 2 = 3 Then
Timer1.Enabled = False
g.DrawLine(Pens.Green, all_lines(i).point1.X, all_lines(i).point1.Y, all_lines(i).point2.X, all_lines(i).point2.Y)
PictureBox1.Image = screen
MsgBox("c")
Timer1.Enabled = True
End If
'primeiro ponto, numa beira encontrado
curren_line_streak.Add(all_lines(i))
If is_point_on_edge(all_lines(i).point1) Then
wanted_point = all_lines(i).point2
Else
wanted_point = all_lines(i).point1
End If
'ja foi iniciada a minha streak
For j = 0 To all_lines.Count - 1
found_a_line = False
If point_equals(all_lines(j).point1, wanted_point) Or point_equals(all_lines(j).point2, wanted_point) Then
If is_repeated(curren_line_streak, all_lines(j)) = False Then
'esta linha encaixa!!!
'ver qual o ponto que encaixa
If point_equals(all_lines(j).point1, wanted_point) Then
'e o ponto 1 que encaixa
wanted_point = all_lines(j).point2
Else
wanted_point = all_lines(j).point1
End If
curren_line_streak.Add(all_lines(j))
found_a_line = True
End If
End If
If found_a_line = True Then
j = -1
End If
Next
'a linha esta completa agora
If curren_line_streak.Count > 2 Then
'a linha tem tamanho suficiente
If is_point_on_edge(curren_line_streak(curren_line_streak.Count - 1).point1) Or is_point_on_edge(curren_line_streak(curren_line_streak.Count - 1).point2) Then
'a linha final toca numa edge!!!!!
'construir a minha streak
For z = 0 To curren_line_streak.Count - 1
current_formal_streak.add_element(New line_streak_element(find_correspondent_hex(curren_line_streak(z)), curren_line_streak(z)))
Next
complete_streaks.Add(current_formal_streak)
End If
End If
End If
Next
[\code]
it is way too long for the task it is.
i keep believing that a simpler better way exists to achive the same goal
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|