Skip to main content
gamedev.net
🔒 Locked

MAP-TILE PROBLEM!!! (Devise Algorithm!!!)

Started by Memir 1 reply 300+ views
Original Post
Memir
Memir
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
Flash Pool - Pool/Billiards game for Facebook (developed by Memir).
omegasyphon
omegasyphon
first off you keep changing your map everytime u write it
i dont know if that is on purpose but do this:

_AABBB 0= _
CAAB__ 1= a
_AAA__ 2= b
__A___ 3= c

011222
311200
011100
001000

then save it in an array called map or whatever

cntr=0
for y=1, y<=4, y++
for x=1, x<=6, x++
if map(y,x)==cntr
drawobject(y*height,x*width)
cntr++
end x
end y
Ironblayde
Ironblayde
Hmmmmmmmmm... smells kinda like a homework problem to me. But oh well, heh. You could find every rectangle on the map such that no rectangle is completely enclosed by another (not hard to do), then starting with the smallest ones and working your way up, remove each rectangle if each tile it encloses is also enclosed by at least one other rectangle. Just like finding prime implicants on a Karnaugh-map.

-Ironblayde
 Aeon Software

The following sentence is true.
The preceding sentence is false.
"Your superior intellect is no match for our puny weapons!"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.