I am no programming expert whatsoever, but wouldn't a more easy system be to give cliffs a code for what type of ending they have? And to that ending only certain tiles from a pool with a specific ending can be placed.
Here's an example of what I mean:
The endings maybe got a bit strange name (L= left, R = right, s= south, n = north and T=top land, B = bottom land, and... doh I mixed up the R because it also means right land...)
Anyway, what I meant was: a tile-ending has 2 elements: the place
where the land is (top, bottom, left, right) and the
direction of the tile ending (north, south, left, right). For each ending there is only one other ending that fits. In the example the NR can only connect to SR tiles (and SR only to NR).
When NR needs a tile you randomly draw a tile from the SR pool. In this case there are only 2 tiles with SR and it could in fact be the 2nd tile with the RB ending! When that one is drawn you will no longer draw from the SR pool, but from the LB pool.
You could even assign chances to each tile by saying it standard has chance = 1 to be drawn. But depending on other variables the chance changes. E.g.: when the user has slided the rivers variable to low, then the "Rivershore-tiles chance to be drawn" lowers proportionally.
Hope it is udnerstandable what I mean.
*edit: the piece itself is also in the SR-pool by the way, since it also has an SR-side (and its also in the NR pool as it has an NR side).