Friday, February 26, 2010

Coder Journey

Listening to a random Reddit-linked YouTube clip of a man carving a Big Daddy Alpha Series out of wood. There is a Bioshock medley playing in the background... and it has some grand violin flourishes. You know the ones -- the lone violin reaches some high note while the rest of the strings do that background noise thing they do.
There is one point near the end of the clip when one of those flourishes occurs and it sends shivers through me. This happens to me with this style of violin, and I get a really sad feeling. I decided to meditate over that feeling and ended up having a small journey.

It started out at the base of a hill. There was a small door with a huge wooden statue of the Moose over it. I went in and headed down the red-carpeted steps faster than I usually do. I opened the door revealing a hilly area where the colors did not make any sense. I saw the Moose and started walking toward him but it was one of those illusions where I keep walking and get no closer. Eventually I went into a hole in the ground and slid down into an area that looked like Rapture. There was only one room with a glass wall to the ocean outside. I saw the Moose floating there, and I put my hand on the glass. He put his hand there in return and then slammed his face into the glass and screamed. I stepped back and turned around to see the room had expanded, to a kind of hall. There was an indent in the middle of the room. There was water coming down from a crack in the glass ceiling. It formed into a small stream that defied gravity and went up the small 2 steps leading into the indent. I followed it and it lead me down a tube where the floor was curved and got higher and higher until I was crawling with the water in my face, still following it down. The tube opened up some and I fell, and I saw the tube circle back into the rock that was supporting the first room. I didn't want to leave the tube, or leave Rapture, or maybe I didn't want to go into the rock. But I did, and it lead down some sharp steps. The rock was an inversion of my first meditation plateau. I followed the water to the bottom where it just vanished into nothing, and there was nowhere for me to go. I felt very sad and nervous. Then the Moose started coming down the steps, two or three of them. I got on my knees, my hand touching the floor where the water was disappearing. I saw random images at this point, one of which being a whale and the other being a guardian I had seen before. They were all fleeting. Suddenly, I appeared on a wheat or tall grass filled plain and I saw the girl I usually see when I meditate, who lives across the river. I reached out to her but the same illusion occurred where I walked but got no closer, but in reverse. I just reached and it was like her and her surroundings were pulling away. Then I was back at the bottom of the rock, and the Moose was on top of me, enveloping me and we sank into the Rock. I lost track of myself then.

I think there are two places to go when you meditate. You can expand your presence and see how far up you can go, or you can shrink your presence and see how far down you can go. The journey ended and I felt so incredibly minuscule. But I also felt like I had found something.

I think many of us are afraid to look too deeply inside. Religions seem to all play to the opposite, and go up as high as you can. We should go to both ends when we ponder that which we are trying to understand.

Tuesday, February 23, 2010

Automation

No nice code snippets to show this time, but hey, we have liftoff!

Caveats:
  • I'm re-reading the doors every time a tile is rotated or flipped. This isn't what I had envisioned initially, but it works. The problem with my last post was, while it worked, it didn't work with the tile randomizer I envisioned. The automator relies on finding an open door on the floor somewhere and keeping that as the "potential door." The automator then shuffles through all available tiles, and when it finds one with a matching door, proceeds with flipping it and moving it around until it can be placed. If we rotate the tile in this process, we lose track of which door it was selected to fit into the potential door. Re-reading the doors after rotation also loses the original potential door, but finds a new one in it's place. Granted, this could be done with the old method too, but frankly it was easier this way. The old way also didn't work with rectangular tiles.
  • Automation is not fully complete, although it is a huge step forward. There are times when I'll end up with open doors and tiles that I know will fit, but the automator has run out of iterations.
To get this far I had to take a step back from the automator I had in place, and essentially re-write it. When the manual placer placed a tile, we have a concept of a "tile position" which is the upper left corner of the tile. The automator had no such luxury. We had to decipher the tile position given only the position of the potential door and the inner position of the selected tile.
There are a few places in the code where I got screwed up with this logic, and it was hard to track down where I messed up until I started over.

My original plan is still what I ended up sticking with! I got caught up with figuring this out and threw out Orientation in favor of Direction, thinking knowing more would help me out. However, how do you determine direction? I thought it was easy, but ended up being not worth it at all.

This is also a good example of where the brain is superior to the CPU. We can look at two jigsaw pieces and see if they fit relatively easily. A jigsaw puzzle is essentially what this automator is. A CPU, though, has no such luxury. Our brains can get caught up in making a seemingly easy task understandable by a purely logical system that can only evaluate one thing at a time.

Bugs I won;t make again:
  1. I assumed only one door could match a time, and only removed one door at a time when placing.
  2. I tested with doors that took up all of one side, missing a bug where the vertical/horizontal displacement of a door had to be taken into account.