# How to properly generate walls simulating perspective around stone in a cave-like level made of squares?

Long story short. My levels tiles currently look like this:

And i want them to look like this:

My levels are designed as 400x400 squares of proceduraly generated 0's and 1's, 0 representing dirt(walkable by player), 1 represeting stone(impenetrable). Game itself looks a lot like this.

At first, my method was to run another loop - after generating the world that replaced stone tiles, depending on directions of empty tiles were, with wall. The method doesn't work so bad up to the point where there are 1 wide walls sticking out, which are impossible for it to convert, check picture:

As you can see, in my method, the wall is an another texture, taking one tile itself. I can't replace air with walls, as that could possibly obstruct a passage. It basically fails every time there are 3 or more dirt tiles directly next to it.

This is the place at which i wondered if i chose the right method or if i should change the whole design for the walls, if so - to what? Should i create some textures for the 1-wides alone? Or maybe i shouldn't generate 1-wides at all? How do games generally deal with this?

I've looked for the answer to my problem, and haven't found it. Probably because it's hard for me to word it(sorry for messy post).

• Can you make it more visually clear what is wrong with your approach? I don't get your problem. – Tinco Jul 20 '14 at 17:59
• You should use an autotiling algorithm to display the walls. (See saltgames.com/2010/a-bitwise-method-for-applying-tilemaps) The example stand for a platformer, but i'm personnaly using it to display caves similar to what you want to achieve. – Khopa Jul 20 '14 at 21:15
• @Tinco Yeah, not strange, it was very hard to word for me. Trying to make it simpler: I can't figure out the proper way to create walling around stone in a level. – Inquisition Jul 20 '14 at 23:05
• @Khopa That is a brilliant link! Thank you, i will probably use it as game develops, answer provided below by Mario fits me fine for what i need now, but the site you provided answers my problem ultimately, thanks. – Inquisition Jul 20 '14 at 23:07