Each edge of a tile is either:-
a) Unique, in which case it is one of the border edges
b) Paired with only one other edge (possibly one being reversed)
As grams says, non-corner edges only have one unique edge (even considering flipping). Corner edges have two adjacent unique edges (even considering flipping).
There's no need for any searching at all.
I processed all tiles and built up a hash/dictionary of edge "numbers" (treating the edge as binary) to tile number. (I took care of the possibility of 'flipped' tiles by also storing the "numbers" associated with the reverse of each of the edges).
So each tile has 8 "numbers" that map to it.
You start by finding a corner (because it has two adjacent unique edges). Rotate it so that the two unique edges point outwards (I started top left so the top and left edges needed to be unique). And then the finding an adjacent tile is simply a case of looking up the corresponding edge number in the hash/dictionary (and ignoring the tile number you already have in place) to get the corresponding tile number. Obviously you may need to flip/rotate the tile you find to get it to fit. Lather, rinse, repeat.
Each edge of a tile is either:-
a) Unique, in which case it is one of the border edges
b) Paired with only one other edge (possibly one being reversed)
As grams says, non-corner edges only have one unique edge (even considering flipping). Corner edges have two adjacent unique edges (even considering flipping).
There's no need for any searching at all.
I processed all tiles and built up a hash/dictionary of edge "numbers" (treating the edge as binary) to tile number. (I took care of the possibility of 'flipped' tiles by also storing the "numbers" associated with the reverse of each of the edges).
So each tile has 8 "numbers" that map to it.
You start by finding a corner (because it has two adjacent unique edges). Rotate it so that the two unique edges point outwards (I started top left so the top and left edges needed to be unique). And then the finding an adjacent tile is simply a case of looking up the corresponding edge number in the hash/dictionary (and ignoring the tile number you already have in place) to get the corresponding tile number. Obviously you may need to flip/rotate the tile you find to get it to fit. Lather, rinse, repeat.