• Status: Solved
• Priority: Medium
• Security: Public
• Views: 200

# logic theory problem

1
/                                              \
17                                               2
/                \                                 /                \
25                  18                       10                     3
/     \                /       \               /         \               /      \
29     26         22         19          14        11          7        4
/  \       /  \        /    \       /    \       /    \        /  \         /  \       /  \
31 30  28 27   24    23  21   20  16  15   13  12     9   8    6    5

I have a structure of pictureBoxes arranged in the format above.

I have a series of steps consisting of step number and branch possibilities of (0,1,2).
They are in an array in such a way as this: 1,2,2,2,3,2,4,1,5,0,6,2,7,1....
like {step#},{branches},{step#},{branches},...

Let me explain how this works.
pic1, if it branches 1 time, next pic is pic2. From pic2, if it branches 2 times, next pic is pic3. if pic3 branches 1, next pic is pic4. if pic4 has no branches, I need to send it to pic10.
The order of the array for the above scenario is:1,1,2,2,3,1,4,0,5,2,....
Now if pic3 had 2 branches, step 5 would have needed to go to pic7.

Any help at all on probably solutions will be appreciated.
0
stevengrogan
• 4
• 3
1 Solution

Middle School Assistant TeacherCommented:
I'm intrigued...but need more in depth discussion of how it's supposed to work...

What do you mean by if it "branches" 0, 1, or 2 times?  Is this like a left/right decision?
What is happening when pic4 has no branches?  Why does it go to pic10?

What is the real world application of this?
0

Author Commented:
It is based from output from a complex texturing layering application's text based output. There are different base classes of texturing filters that affect having 1,2 inputs(aka-branches), or the 0 stands for a base color or texture image as the input. The text output file is linear, so that the text  is output for the far right branch till it reaches either a color or texture image. Then the text files next section is output from the next higher branch that had 2 inputs, and carries down that chain until it reaches either a color or texture image.

Sorry for the text visual of the tree, not lined up perfectly.

When pic4 has 0 branches, it travels back up its chain until it reaches the next pic that had 2 inputs(branches), and travels down the other branch, following a far right rule again. so after pic4, since in the example pic3 had only one input(branch), it moves to pic2 which had 2 inputs(branches) and travels down the untraveled branch to pic10.

To further down the chain from pic10, it would go down to pic11 then pic12 till it reaches a 0 branch pic.

I guess to sum its travel logic after pic4, go back up chain till we can move left(pic with 2 inputs(branches)), then stay to the right down that chain until we encounter another 0.

The application is to aid in visually displaying the entire chain, (The existing program only allows viewing current layer, and requires drilling down through layers, loosing place is easy to do)

The pics will actually represent various filters i.e.(noise,height,slope,blend,etc.)
0

Author Commented:
here is a jpg of the structure, it is a circular structure for screen constraints, but the number link is easier to see.
boardexample.jpg
0

Middle School Assistant TeacherCommented:
Ok..it sounds like a problem that can be represented by a graph/tree and solved using recursion.  Do you currently have a "node" class to represent this thing?...or is that the part you are asking for help with?

Is the number of nodes fixed?  Where does the STRUCTURE (which nodes connect to which others) come from? etc...

Would love to help...just need a better idea of where you are so I can jump on in.
0

Author Commented:
That is my dilema. There is no set count on the number of nodes(pics) a given file will have. Also, no definite structure, as a noise filter can use any of the others as one of its inputs (color and height), while another noise could be using( noise and noise) for its inputs.

I have a separate class for each type of filter, as each has a slightly different structure, where possible, I have used inheritance from the noise class, as it has a close to generic layout with 2 inputs.

The bottom end(base structure) would be the color or texture classes, as these cannot have a further branch(child). Here is an example of one class: The noise class:

Also attached is an actual text file of one texture that I am reading in.
``````Public Class noiseTexture
Protected m_type As String
Protected m_title As String
Protected m_upperthreshold As String
Protected m_lowerthreshold As String
Protected m_seed As String
Protected m_firstoctave As String
Protected m_octavecount As String
Protected m_image As Bitmap

Public Property type()
Get
Return m_type
End Get
Set(ByVal value)
m_type = value
End Set
End Property

Public Property title()
Get
Return m_title
End Get
Set(ByVal value)
m_title = value
End Set
End Property

Public Property upperthreshold()
Get
Return m_upperthreshold
End Get
Set(ByVal value)
m_upperthreshold = value
End Set
End Property

Public Property lowerthreshold()
Get
Return m_lowerthreshold
End Get
Set(ByVal value)
m_lowerthreshold = value
End Set
End Property

Public Property seed()
Get
Return m_seed
End Get
Set(ByVal value)
m_seed = value
End Set
End Property

Public Property firstoctave()
Get
Return m_firstoctave
End Get
Set(ByVal value)
m_firstoctave = value
End Set
End Property

Public Property octavecount()
Get
Return m_octavecount
End Get
Set(ByVal value)
m_octavecount = value
End Set
End Property

Public Property imageicon()
Get
Return m_image
End Get
Set(ByVal value)
m_image = value 'My.Resources.no
End Set
End Property

Public Sub New()
m_type = "noise"
m_image = My.Resources.no
End Sub

Public Sub New(ByVal type As String, ByVal title As String, ByVal upperthreshold As String, ByVal lowerthreshold As String, ByVal seed As String, ByVal firstoctave As String, ByVal octavecount As String)
m_type = type
m_title = title
m_upperthreshold = upperthreshold
m_lowerthreshold = lowerthreshold
m_seed = seed
m_firstoctave = firstoctave
m_octavecount = octavecount
m_image = My.Resources.no
End Sub

Public Function combined() As String
Dim mystring As String
mystring = m_type & vbCrLf _
& m_title & vbCrLf _
& "Threshold: " & m_upperthreshold & " to " & m_lowerthreshold _
& vbCrLf _
& "Seed: " & m_seed & "  1st Oct: " & m_firstoctave & "  Oct Count: " & m_octavecount & vbCrLf
Return mystring

End Function
End Class
``````
coolgrassdirt.txt
0

Author Commented:
The node/recursion sounds like the solution, just trying to get mind around navigating through it with the steps that occur in such seemingly random but structured order. The classes I have so far could count as nodes of aa overall node class. Commented coolgrassdirt.txt file below with accompanying diagram:

layer.1.0
*** Step 1 start  would be pic1, noise: so has 2 branches***
noise
coolgrassdirt
0.5
0.4
12210
3
7
*** Step 1 end ***
*** Step 2 start  would be pic2 noise:so has 2 branches***
noise

0
0.85
8530
1
9
*** step 2 end ***
*** step 3 start  would be pic3, noise: so has 2 branches ***
noise

0.34
0.58
39739
1
9
*** step 3 end ***
*** step 4 start would be pic4, noise: so has 2 branches ***
noise

0.6
1
1398
1
9
*** step 4 end ***
*** step 5 start, would be pic5, color: so no branches, need to look back up tree for 2 branch node ***
color
-16768992
*** step 5 end ***
*** step 6 start, would be pic8,noise, so 2 branches ***
noise

0
0.74
18167
1
9
*** step 6 end ***
*** step 7 start, would be pic9, color: so no branches,need to look back up tree for 2 branch node ***
color
-16760768
*** step 7 end ***
*** step 8 start, would be pic10, color: so no branches,need to look back up tree for 2 branch node ***
color
-16765696
*** step 8 end ***
*** step 9 start, would be pic11, noise: so 2 branches ***
noise

0
0.74
43741
1
9
*** Step 9 end ***
*** Step 10 start,would be pic12,color:so no branch, move up tree ***
color
-16756480
*** Step 10 end ***
*** Step 11 start , would be pic15,color: so no branch, move up tree to next 2 branch pic***
color
-16751053
*** Step 11 end ***
*** Step 12 start,would be pic18,noise, so 2 branches ***
noise

0
0.76
58601
1
9
*** Step 12 end ***
*** Step 13 start,would be pic19,noise:so 2 branches ***
noise

0
0.86
20780
1
9
*** Step 13 end ***
*** Step 14 start, would be pic20,color:so no branch,need to look back up tree for 2 branch node ***
color
-10011112
*** Step 14 end ***
*** Step 15, would be pic23,noise: so 2 branches ***
noise

0
0.88
5889
3
7
*** step 15 end ***
*** step 16 start, would be pic24,color:so no branch,need to look back up tree for 2 branch node ***
color
-9816832
*** step 16 end ***
*** step 17 start, would be pic25,color:so no branch,need to look back up tree for 2 branch node ***
color
-12961757
*** step 17 end ***
*** step 18 start, would be pic26,color:so no branch,need to look back up tree for 2 branch node ***
color
-13165568
*** step 18 end ***
*** step 19 start, would be pic33,noise:so 2 branches ***
noise

0
0.91
46423
1
9
*** Step 19 end ***
*** Step 20 start, would be pic34,noise:so 2 branches ***
noise

0.2
0.62
12525
1
9
*** Step 20 end ***
*** Step 21 start,would be pic35,color:so no branch,need to look back up tree for 2 branch node ***
color
-16768000
*** Step 21 end ***
*** Step 22 start, would be pic42,color:so no branch,need to look back up tree for 2 branch node ***
color
-11173047
*** Step 22 end ***
*** Step 23 start,would be pic49,noise,so 2 branches ***
noise

0
0.79
58871
1
9
*** Step 23 end ***
*** step 24 start,would be pic50,color:so no branch,need to look back up tree for 2 branch node ***
color
-8372224
*** step 24 end ***
*** step 25 start,would be pic57,color:so no branch, no where else to go, end ***
color
-16499676
*** step 25 end***

boardexample2.jpg
0

Middle School Assistant TeacherCommented:
Sorry I haven't gotten back to this question yet stevengrogan.  If you leave it open I may be able to post something in the next couple of days.
0

## Featured Post

• 4
• 3
Tackle projects and never again get stuck behind a technical roadblock.