The hardest part about creating the Celtic Doodler was translating the human-ready
algorithm (taught to me by the mystery woman) into an algorithm a computer
could understand.
Peter Gruhn's
Web page gives a pretty good variation on how I used to draw these things
by hand.
After lengthy contemplation, I realized the doodles could be
broken into a small set of tiles and then arranged appropriately. Here's the set:
One thing to notice is that these 16 tiles can be reduced to six
varieties:
Once I realized this, I was home free. All I had to do was create a Java
object that represents a tile cell, tell the cell what it should look like (depending
on which sides of the cell were closed), and devise an interface that would make it
easy for people to close off different walls of the cells, without really knowing
that's what they're doing.
Designing the interface was tough. First, I needed to draw the tiles and get
them to line up. That was a pain. Luckily, I wormed my way out of this onerous
task by getting my friend Jillo
addicted to knot doodling. Once her obsession grew, she needed the program as badly
as I did, so it was easy to convince her to do the graphics. Here's her story:
When Thau asked me to help, I was, of course, very honored. I mean - my stars!
- how often do you get to assist someone in fulfilling their lifelong
dream? First, I drew a doodle on paper, because I'm not very good
at free drawing on the computer. Then I scanned it and brought it into
Photoshop, where I proceeded to chop it into 50- by 50-pixel squares.
I took one of each of the six varieties and rotated it as necessary to make the full set of 16 tiles. That's where the fun ended. Next, I had to match up each piece against all the others to make sure they aligned correctly.
If that made sense to you, you've clearly spent too much time doodling.
Luckily, I got to skip that stuff. Once we had the images for the tiles, and
I'd programmed up the Java tile object, all I had to do was plop a bunch of the
objects on a page, and voilà! Done!
Well, almost. Another tough part was getting the tiles to communicate with
each other. All the user interaction happens at the corners, where the tiles meet.
Any time someone clicks on a corner, all the tiles around that corner must be told.
Also, if a user clicks on one tile to start a wall, and then clicks on the other side
of the board, the first tile she clicked has to be told to unclick itself.
So, right now there's a bunch of code in the tile object that tells tiles
how to communicate with their neighbors. Eventually, I might create a corner object that
handles all the communication between neighboring tiles. Maybe next time you check here,
I'll have already done it. I'd also like to network this so that more than one person can
play with the same board at once. Just give me a few weeks....