2 Replies Latest reply on Jun 14, 2007 4:11 AM by Newsgroup_User

    spatial distribution

    Level 7

      Hi all,

      I'm looking for an algorithm which distributes a set number of squares
      across a fixed size plane in a nice random manner.

      In a memory/match game I want the cards not arranged in a grid
      (preferably not even a grid with some freedom of movement in it's
      squares) but in a true random fashion.
      I tried to find algorithms on the web, but the ones I found did not
      match my problem (or I missed it)

      Does anyone knowmaybe a name of such an algorithm or have any (pseudo)code?

      Thanks in advance,
      Manno

      --
      ----------
      Manno Bult
      http://www.aloft.nl
        • 1. Re: spatial distribution
          Level 7
          Try searching Google for 'scatter algorithm' - at least that's what the 3D
          versions are called. That being said, it seems like starting with a grid is
          a good idea - if you want to cover the whole plane. Maybe divide the plane
          into 2 or 3 times as many squares as there are cards and then randomly pick
          x squares to put cards on. From there you could move each card a random x,y
          amount... seems like it would work.

          --
          Dave -
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: spatial distribution
            Level 7

            Hi Dave,

            thanks. "scatter" did not come to mind. Should have though...(*)
            Your idea of devideing the field in more squares than needed sounds good
            too, I'll have a go to see if it does not take up too much screen etstate.
            Thanks again,
            Manno


            (*)
            George: "If we should happen to tread on a mine, what do we do?"
            Black adder: "Well, normal procedure, luitenant, is to jump 200 feet
            into the air, and scatter yourself over a wide area"

            DMennenoh **AdobeCommunityExpert** wrote:
            > Try searching Google for 'scatter algorithm' - at least that's what the 3D
            > versions are called. That being said, it seems like starting with a grid is
            > a good idea - if you want to cover the whole plane. Maybe divide the plane
            > into 2 or 3 times as many squares as there are cards and then randomly pick
            > x squares to put cards on. From there you could move each card a random x,y
            > amount... seems like it would work.
            >

            --
            ----------
            Manno Bult
            http://www.aloft.nl