magic square topograhical model

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • magic man
    New Member
    • Aug 2007
    • 4

    magic square topograhical model

    I need help ... I have very rudimentary VB skills. I am working on a topographical model of a magic square. I consider each cell in the square to be a solid structure to the height specified by the value in the square. Then conceptually I pour water on the structure and wish to see where the water collects in "lakes" on the structure.

    What I think I need is a program that will generate all unique paths from a cell in the interior of the square to the exterior of the cell. I can readily search those paths for the one with the least high obstruction on the way out.

    I would like a program that for and order of square will generate the unique paths out ?

    Very appreciative for any help on my project

    Thanks
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    It sounds as though you should go to the Software Development forum to get some info on how to go about this. Once you've got the method, I believe we will be able to convert it to VB quite simply.

    Comment

    • magic man
      New Member
      • Aug 2007
      • 4

      #3
      Originally posted by Killer42
      It sounds as though you should go to the Software Development forum to get some info on how to go about this. Once you've got the method, I believe we will be able to convert it to VB quite simply.
      I feel a little embarrased asking someone else to do my work ... but I just don't seem to have the mental horsepower to get it done ...

      I emailed a lot of Einstein type people in the math field and got two replies on how I should approach this ...

      Just for general interest ... there are 880 different 4x4 magic squares.

      There are 3600 different 5x5 magic squares .. of a special variety .. they call pandiagonal magic squares. Harvey Heinz has them enumerated on his web site on magic squares .. so I can search through those examples for my data ..

      ... but I digress ...

      *************** *************** *

      A real nice guy called paul black @nist.gov ... ? some government guy for algorithm standards emailed me back and said I had to do the following..

      #1. "you should use a depth-first algorithm with flags to avoid loops "

      ( I have no acquaintance with that)

      #2. "for each cell in the interior find every path from c to the exterior...

      he refers to this fct as FAREPFHTTE

      FAREPFHTTE (C)

      for each direction up (+1 0), down (-1 0), left (0 +1), and right (0 -1)
      nextc = c+ direction

      if nextc is already in the path, skip it
      if nextc is exterior, report path
      otherwise call FAREPFHTTE(next c)


      *** paths cannot take diagonals ***

      we don't want the program to try up, down, up, down over and over so how can we mark that the cell is already in the path? Well keep an array of cells and mark each one as we take it ( and unmark each one as we leave it) so now it is

      FAREPFHTTE(C)

      A(c) = 1 # mark that c is in use
      for each direction up (+1 0 ), down (-1 0), left (0 +1) and right (0 -1)

      nextc = c + direction

      if A(nextc) is 1 , try next direction # it is already in the path, skip it

      if nextc is exterior, Print P #print what we have

      otherwise call FAREPFHTTE (nextc,P."nextc ")

      A(c) = 0 # mark that c is no longer used



      *************** *************** ****



      I have tried to just write by hand ... all the unique paths from one coner inner cell for the 5x5 square and got 91 unique different paths ....


      I have never written a recurssive program ... just for next loops and I know how to insert a simple sort program ... so I can easily sort the paths once I have them. I can also write the code to rotate the square ... so once I have the soln for a given interior square .. I can rotate the orginal square ... and thus for 5x5 square ...only have to define 3 differnt cells in that square ...

      ********

      Lastly I enclose a picture of a order 5 magic square that I made a "mass" model for

      Thanks alot

      well I guess I don't know how to insert a picture in this email

      Craig

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        I won't have time to look into this for a while. In the meantime, you might want to have a look at the entry on Wikipedia, and I really do think you should put an entry in the Cafe/Lounge, or Software Development forum. This sort of question should have wider exposure than just the VB forum.

        I can move the thread over there, if you like, so you don't have to do it all again.

        Comment

        • magic man
          New Member
          • Aug 2007
          • 4

          #5
          Thanks for your kind help. I took your suggestion and posted the problem on the link you gave me. I feel certain that someone has solved this problem in the past .. and there is no sense in me reinventing the wheel ....

          I have been caught up in the muse of the symmetry of the magic square structure. I have yet to find someone who has developed a practical use for it ... thus the model building effort. Harvey Heinz has a great web site on magic squares.

          I have a model assigning weights to the cells ... that a physics professor - Peter Loly has written several papers on the moment of inertia and the harmonics/eigen values of such structures...

          The topographical model ... I think will be of interest ...

          and am trying to invent a time model for the magic square structure

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by magic man
            ... I have been caught up in the muse of the symmetry of the magic square structure. I have yet to find someone who has developed a practical use for it ... thus the model building effort. Harvey Heinz has a great web site on magic squares.
            I thought the Wikipedia article mentioned a few purposes they have been used for. I didn't read it in detail, though - just skimmed briefly.

            Comment

            Working...