Algorithm / Rule design

Discussion in 'Computer Science & Culture' started by AntonK, Feb 27, 2003.

Thread Status:
Not open for further replies.
  1. AntonK Technomage Registered Senior Member

    Messages:
    1,083
    Okay, this is my second post, the first one didnt go through because the file was too big, but lets try again.

    I have to come up with a good general algorithm/set of rules for the following problem.

    I have an array of a structure called Box. Box contains the following ints: x,y,w,h. This obvious describes the box's size and location. The array is of size n. The screen is of size X by Y, typically 800 x 600. Given these boxes, as displayed in the picture, and an integer which holds the array index of the box "currently selected". We can assume that the boxes do not overlap. What I need is an algorithm that will select which box is to the right/left/up/down from the currently selected. I realize there isnt always a "math" solution to which one would be to the left/right/up/down. What i need are a set of rules that can choose it so that it is intuitive. If a group of people were to all say "yes, that one is on the left of that one" then that should be the one selected. Sometimes there wont always be an obvious selection, but it should be intuitive. For instance, given two that are equally probable, select the larger one before the smaller one.

    The picture basically shows what I am meaning. Remember that the answer can be none if there isnt one to the left/right/up/down of the currently selected.

    Thanks again everyone. If you need more clarification, I check the board often. Thanks

    -AntonK
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. AntonK Technomage Registered Senior Member

    Messages:
    1,083
    no one???

    Come on...anyone?

    Please Register or Log in to view the hidden image!


    I was hoping some people could at least help me establish some rule based design...guess all anyone here cares about is talking about dna computers and quantum algorithms.

    -AntonL
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. Adam §Þ@ç€ MØnk€¥ Registered Senior Member

    Messages:
    7,415
    Sorry, too sleepy. I'll have a go tomorrow.
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. BloodSuckingGerbile Master of Puppets Registered Senior Member

    Messages:
    440
    What if it's above and to the left, like the 1st in relation to the 6th in your drawing? It would be left-above? Or just left, or just above, or undefined?

    Please Register or Log in to view the hidden image!

     
  8. AntonK Technomage Registered Senior Member

    Messages:
    1,083
    well in the drawing i tried to show what each one would "intuitively" (tell me if u think another one would be more intuitive) have as its up/down/right/left.

    so the 1st wouldnt be the up/down/left/right to the 6th. It wouldnt be anything in relation to 6th. See what i mean?

    This started off as a menu system im building for another project. But when i hit this problem i decided i could either define the relations manually or try to get an algorithm to do it and decided it would be a fun problem to solve and to come up with a rule system for.

    -AntonK
     
  9. BloodSuckingGerbile Master of Puppets Registered Senior Member

    Messages:
    440
    hmm...

    Maybe you shouldn't use math. Maybe you should try solving it graphically.
    Try tracing the boxes. Assuming that you have a fixed border color of the boxes, read the pixel colors to the left of the currently selected box until the box border color is returned and then check in the structure array to see if the border is a part of a box. Same thing, do it above, to the right and below the box.
    I tried the graphical method once, to find a line intersection on the screen. It's pretty slow, but if speed is not an issue, it should do the job, if I understood your problem right, of course.
     
Thread Status:
Not open for further replies.

Share This Page