Start with green flag, then move around using the cursor keys. Feel free to incorporate the algorithm into your games or to remix with different graphical styles. The maps don't need to have roads, they just need to be able to abut to tiles that have edges which fall into one of two classes. Here the classes are road/no road, but they could as easily be land/water or hill/grass... See https://scratch.mit.edu/projects/102170546/ for a version that limits the size of the map to a maximum number of non-empty tiles.
EVEN BETTER: Latest version, totally rewritten, more features: UPDATED VERSION AT https://scratch.mit.edu/projects/114733627/ INCLUDES A BUG FIX! This is a map generator that produces connected roads in the style of Carcassonne games. It guarantees that there are no unconnected edges at the boundaries between cells, however it is not a fully-connected graph. There are road segments that never join up with other road segments. The algorithm is stateless and always generates the same cell for any x/y coordinate, as long as the initial random number pool is not reloaded. The graphics are rather crude, but are easily replaced with any sprites that are square and have roads which enter at the centers of the sides. The density/style of the generated maps can be tweaked by altering the probabilities of the pseudo-random tests. (hashval) You could also have multiple costume versions for any specific topological connection, to give some variety. Another thing you can do with this algorithm is start from a single cell in the center and only draw connected cells, including when you scroll. This generates a fully connected map, albeit of random dimensions. A breadth-first or even depth-first search from the starting point is used to determine whether the size of the graph is between some minimum and maximum. This is demonstrated in