Marching squares - is an algorithm that can generate contour for scalar field (only two-dimensional, for three-dimensional you can look at marching cubes , it has the same idea). It's usually used in computer graphic. Why do we need it? So, let's assume you've generated map as grid of "walls" (we will call it as 1) and empty cells (0). If you'll start placing square tiles at this positions, you will get something like this It could be acceptable for some kinds of RPGs or even strategies, but when you have smooth and fluent gameplay you will stumble on corners of your squares. So you need to make your map smoother. And that's where you need marching squares. Look at the difference: That's how my game looks now: Implementation So, as I said previously, we have a grid of zeros and ones. We can encode every four neighbour cells with four bits, each of them will contain value of corresponding cell. So, if first cell contains "1...