Following Directions (repeatedly)


I found a web page containing some JavaScript I made late last year while cleaning the icons off of my desktop. I’m not sure exactly what inspired me to make it. The page I made said it follows the principle of “three rights make a left”. So maybe I got the idea when I missed a turn while driving.

The application is very simple, and in fact reminds me of a very limited type of Turtle Graphics.

Here are the key facts/constraints about the program:

  1. The “turtle” must move in discrete “cell-sized” increments
  2. The turtle can only be told to move left (L) or right (R)
  3. The turtle moves by turning the direction told, then moving forward one unit
  4. The turtle can only face four directions: up, down, left, and right. No angles in between

The result being that, much like how three rights will make a left while driving, the same applies to the “turtle” in this program:


And four rights will bring it back to where it started:


I’ve uploaded the page here, the source code is in the HTML so just view the page source if you want to see it.

Leave a Reply

Your email address will not be published. Required fields are marked *