Solved

logic theory problem

Posted on 2009-05-13
7
175 Views
Last Modified: 2013-11-27
                                                                                      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
Comment
Question by:stevengrogan
  • 4
  • 3
7 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24376713
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
 
LVL 1

Author Comment

by:stevengrogan
ID: 24377271
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
 
LVL 1

Author Comment

by:stevengrogan
ID: 24377336
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24377662
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
 
LVL 1

Author Comment

by:stevengrogan
ID: 24378396
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

Open in new window

coolgrassdirt.txt
0
 
LVL 1

Accepted Solution

by:
stevengrogan earned 0 total points
ID: 24379278
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
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24452979
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question