You are should look into auto tiling. There are two prevailing methods as to how to implement this.
The first assigns a bit value to each tile type, tile_bit
, and a bit value to each tile surrounding the location, loc_bit
. Multiplying tile_bit
by loc_bit
will give a unique value for every combination of surrounding locations. This very simple to do with only two or three types of tiles.
More details here : http://www.saltgames.com/2010/a-bitwise-method-for-applying-tilemaps/
The second method instead divides each tile up into for sections. These four sections each get a bit value based on their neighbor tile's value. Then you can draw the appropriate tile that matches up with the four bit values. More details here : http://www.codeproject.com/Articles/106884/Implementing-Auto-tiling-Functionality-in-a-Tile-M
Both of these articles assume that you have every combination of transition drawn. This gives you greater control over the look of your map. However, this can get extremely tedious if you have a many tile types. Instead you can dynamics generate edges.
These articles talk about just having generic predrawn edge tiles and assembling them based on your map: http://www.xnaresources.com/default.asp?page=Tutorial:TileEngineSeries:6
This other topic also talks about even generating edges instead of drawing them. However I think this will just lead to a very crude edge most of the time: Map tile terrain transitions with 3-4 different typesMap tile terrain transitions with 3-4 different types