Ray Casting in 2D Top DownTiles
http://www.codeproject.com/Articles/15604/Ray-casting-in-a-2D-tile-based-environment
Auto Tiling/Laying Tiles Programtically/TileLaying algoithm
http://www.saltgames.com/2010/a-bitwise-method-for-applying-tilemaps/
Other Links
http://stackoverflow.com/questions/8901987/map-tiling-algorithm