Devam Ediyor

475957 PHP grid algorithm 2

NOTE: You need excellent math/logic skills to take this one on!

Task: Create an algorithm that fills a grid with blocks based on certain input variables. Basically, I would like to specify the variables below: the size of the grid, how many blocks and what block sizes to use. The script (PHP would be great) should output all possible grid layouts. To visualize, a 3 x 3 grid might have the following layouts (the numbers represent block ids):

1 2 3

4 6 6

5 6 6

1 2 3

6 6 4

6 6 5

1 6 6

2 6 6

3 4 5

6 6 1

6 6 2

3 4 5

(Input: 3x3 grid, 6 blocks, block types 1x1 and 2x2)

Note that not all input combinations produce valid grids. Ie. there is no way to fill the above 3x3 grid with 5 blocks of type 1x1 or 2x2.

Input:

gridSizeX (i.e. 10)

gridSiteY (i.e. 15)

blockCount (i.e. 20)

blockSizes (i.e. width = 2, height = 2; width = 6, height = 2; etc.)

Output:

JSON with all possible block grids:

"grids":{

"0":{ // the first grid

"gridSizeX":3,

"gridSizeY":3,

"blocks":{

"0":{

"x":0,

"y":0,

"w":1,

"h":1

},

"1":{

"x":0,

"y":1,

"w":1,

"h":1

},

"2":{

"x":0,

"y":2,

"w":1,

"h":1

},

"3":{

"x":1,

"y":0,

"w":1,

"h":1

},

"4":{

"x":1,

"y":1,

"w":2,

"h":2

},

"5":{

"x":2,

"y":0,

"w":1,

"h":1

}

},

},

"1":{ // the second grid

...

I will need this for a simple game that I am making. The algorithm does not need to create the grids on the fly, so it's ok if it takes up to one hour to create all options for a, say, 10x10 grid.

Please see the sample grid I attached (one possible layout for 18x20 grid, 30 blocks, types 2x2, 4x4 and 6x6). The algorithm will need to produce all possible layouts for the given input variables.

Looking forward to your bid.

Steffen

Beceriler: Her şey Kabul, PHP

Daha fazlasını görün: what's an algorithm, what's algorithm, what is the algorithm, what is.json, what is an algorithm, what is algorithm, what is a algorithm, what does algorithm, what an algorithm, what algorithm, visualize json, use of algorithm, use algorithm, types of algorithm, the algorithm is, the algorithm, making an algorithm, logic algorithm, how to use algorithm, how to create an algorithm, how to algorithm, an algorithm is a, an algorithm, algorithm's, algorithm is

İşveren Hakkında:
( 0 değerlendirme ) W?rzburg, Germany

Proje NO: #2221862