OpenGL and Java have been finally fused. The applet below is one of many samples bundled with the Java OpenGL libraries. The sample can be freely copied and distributed. I thought I'd do just that before learning programming OpenGL myself. This is a delightful example of 3d graphics.

The game is a 3d tic-tac-toe, known as tic-toc-tac-toe.

To play the game, drag the mouse.

Oren Patashnick is said to have [WW, p. 674] shown that the player to start the game have a winning strategy. So unlike the original 2d 3×3 game that ends in draw provided the players make no stupid moves, the first player has a chance at winning. This is a theory. As you may observe, it's not at all simple to achieve a win in practice.

How many different ways are there to place 4, say, crosses in a winning streak?

Solution

Consider a 6×6×6 board centered around the given 4×4×4 cube. Each winning line of the latter intersects exactly two 1×1×1 cubes in the outer shell. On the other hand, each such 1×1×1 cube located in the outer shell lies on a single winning line. The total number of the winning lines therefore is given by

(6^{3} - 4^{3}) / 2 = 76.

(You can verify this approach on the common 3×3 board: (5^{2} - 3^{2}) / 2 = 8, as expected.)