Home           About           Downloads





Lights Out puzzle experiment



I wrote this program to see the effect of applying a simple rule for solving the light toggling puzzle.

The idea is, because the toggle pattern is a cross shape, you can toggle one cell in a row at a time by pressing the one below it. Working your way down, you can clear each row separately this way. (According to the rules of the light puzzle, "pressing" a cell means toggling the cells that make up the cross centered on that cell individually.)

Naturally, the interesting thing happens when you reach the bottom. Sometimes it will work itself out, sometimes it won't. When it doesn't, it can produce interesting patterns as you keep applying this algorithm. When the puzzle isn't solved, this program reapplies this technique, but in the other direction.

Press 'r' to generate a new puzzle. (It regenerates a new puzzle by "pressing" 1000 cells at random)
Press 'p' to pause the algorithm.
Press 'c' to continue the algorithm. Pressing it again will modify the speed at which the algorithm runs - whole row per frame, or single cell per frame.

Click to press the indicated cell (will toggle a cross shape at that position). You can do this during a solve as well. You can set up your own puzzle this way, and see how the algorithm handles it.

Screenshots:







Simple tennis program



This program is the beginnings of a tennis simulation featuring some basic tennis mechanics.

This program demonstrates a means of making the ball land anywhere with an arbitrary apex height, and a means of determining which part of the trajectory can be reached by the player.
In this way, the program demonstrates a framework for staging all sorts of different scenarios and tennis playing strategies in the tennis universe.

Description of AI behaviour:

  • AI runs directly toward the ball to intercept it
  • AI runs to the center of its half of the court after hitting the ball and before its opponent does
  • AI decides on where it would like the ball to land by choosing a random spot in opponent's half of the court
  • AI may control the height of the apex of the ball's parabolic trajectory

The parabola the AI desires is precomputed, and an appropriate initial velocity vector is computed for the ball so that the ball follows the desired trajectory under the influence of a physics model which only includes gravity.

The physics ball is rendered as a white sphere, the "scripted" constant x-velocity ball is rendered as a yellow sphere.
I render both to ensure that they match up precisely.

The precomputed parabola is rendered as well. The green portion is the portion that can be reached by the player, the red portion is the portion that cannot be intercepted in time.

In this version, I've made the camera follow the player, so there is no interactivity.

Esc will close the program.

Screenshots: