# Paint game level algorithm

I have a game, and I have a level editor where you can build your level from blocks. Blocks positioned in cells. So blocks can have no neighbours or have one or few neighbours. My problem is that I need to put appropriate texture to block, based on block position related to another blocks. Is there some specific algorithms or methods that can help me?

I want it to update textures after adding/moving/deleting each block so it should be fast.

Levels can look like

- - - - - - - - - - - - - - -
|                            |
|             |- - - |       |
|             |- - - |       |
|                            |
|         - - - - -          |
|         |       |          |
- - - - - |       | - - - - -|