Original Post
Devise an algorithm to solve this problem:
To produce the minimum number of rectangles for a tiled map of array W x H.
e.g:
(a 6x4 tiled map, where '_', 'A', 'B', and 'C' are different tiles)
_AABBB
CAAB__
_AAA__
__A___
A possible solution would be:
_00111
2003__
_004__
__5___
As you can see, now there is only 6 different rectangles ('0' thru '5'), where initially we had 13 tiles.
This solution could be stored as:
( x,y,width,height, tile_index )
1,0,2,3, 'A' (0)
3,0,3,1, 'B' (1)
0,1,1,1, 'C' (2)
3,1,1,1, 'B' (3)
3,2,1,1, 'A' (4)
2,3,1,1, 'A' (5)
I will look forward to see your algorithms!
[If the text doesn't align properly, just copy+paste to notepad and read it]
/Memir
Edited by - Memir on 11/5/00 10:53:22 AM