Thursday, January 29, 2015

Points, Lines, and Randomizing

While trying to sleep last night, I came up with exercise for myself. Build an array of points, each separated by 10 pixels and draw lines between them.

The starting point (point A) is chosen a random. Four conditionals check if the four surrounding points aren't already used and puts them into an array if they aren't. One of the points that qualified is chosen at random (point B). Then a line is drawn from point A to point B. Point B then becomes the starting point and the process is repeated until it hits a dead end. The whole process then starts over picking a new starting point at random from any unused points. The end result turned out to  be something of a maze:



No comments:

Post a Comment