I'm currently working with Phaser, making a game that's procedurally generated. I wanted to use some RPG maker art in my game (for reference, I'm using the RTP). I stumbled across this article, which breaks down how auto tiles work. I also stumbled across this answer which links to another article that explains auto tiling.
Here's the thing, I have no idea how I would implement something like this. I'm sure I would have to keep track of which tile sets can connect to which other tilesets (ie, some tiles have grass on the outside, and sand on the inside, so in this example I'd have to note that "grass" tiles were the outer tiles).
I've made a map generator, and I wanted to make seamless connections between my tile areas. For example, the brown areas would be "dense" areas (forests, caves, etc). The purple areas would be stone floors, and the green area is the grass. There is a tileset that works very well for things like this:
So I would like to use the top left grass, and the third tile set, stone, which connects to the grass.
What sorts of things would I have to consider when implementing auto tiling using these sorts of tilesets, and is there an algorithm I can look at to implement?