[an error occurred while processing this directive]
I decided to create this game because I could find no good Java pool or billiards game on the internet that offered a challenging one player game against the computer. In addition, the games that I could find offered unrealistic physics, poor presentation, showed you the direction of your target ball before you took the shot (and hence were too easy) or animation that was not at all smooth. The animation was the most important factor in the structure of my game. Instead of calculating the positions of each ball during the animation process, the shot is 'taken' before the ball animation begins, with every position calculated at every time interval. The shot is then animated using these precalculated positions and times. Using this method, the animation isn't slowed down by the physical calculations.

There are two main parts to my program: the physics, and the AI for the computer opponent. The physics engine uses momentum, force and acceleration laws to offer an accurate game. Of course in real life, the pool table offers inpurities (such as fluff on the table cloth or cushion, scratches on the balls etc) which alter the outcome of a shot that might otherwise be perfectly lined up. I believe that very small rounding errors used during the calculating progress mimic these real life impurities. The highest skill levelled computer opponent will always attempt a perfect and direct pot (if available). The computer calculates where the ball should be hit in order for the target ball to be perfectly potted. Rounding errors may occasionally cause the ball to rattle the jaws of the pocket and not pot, for example. This point also highlights the fact that the computer doesn't calculate the outcome of the shot before it chooses to take that shot. It calculates where it should hit the target ball in order for it to be potted. This helps to offer a balanced and fair opponent. Techniques that the computer opponent uses are plants, doubles, spin, off the cushion escapes, and smashes, along with direct pots. If the computer thinks that the cue ball is likely to be potted if a certain shot is taken, it will choose an alternative shot.

The physics engine works by breaking down the movement of the balls into very small time intervals (1000th of a second). During every time interval, each ball is moved depending on its velocity and spin at that moment, and then these two values are changed slightly depending on things such as whether the ball has collided with another ball, the ball has collided with a cushion, or with the jaws of a pocket etc. This method insures that gentle shots are accurate, while hard shots may or may not be slightly innaccurate (depending on the 'luck' of the calculations). Once again, like the occasional miss due to rounding errors, this is analogous to the real life situation.

A foul is committed if: the first ball to be hit is not the current players colour, no ball is hit at all, a potted ball is not the current players colour, the black is potted before all of the players colours, or the cue ball is potted. A players colour is decided by the first ball that he pots. If a player pots one of his colours and a foul is not committed, he is rewarded with another shot. If a player pots the black without committing a foul, he wins. If a foul has been committed, his opponent wins. Since computer pool is easier than real life pool, I decided to omit the popular British rule of a player being awarded two shots after a foul is committed. In a two player game, the players are free to choose their own rules, as there are no programmed two player rules. Disputes may be settled by using the replay function. I decided to include a computer versus computer mode simply because it only involved a few extra lines of code. In this mode, both computers have the highest skill level, and they play using the same rules as a one player game.

I tried to make the program as simple as possible to use. There are only four main points to remember whilst playing the game:

  • To add spin to the cue ball, move the cross in the top right corner.
  • To zoom in on any ball (making it easier, but not too easy, to line up the shot) right click on the ball.
  • To hit any ball dead centre, left click on the ball.
  • To change the strength of the shot, move the power bar.
These points are explained, with illustrations, at http://www.kevinbertman.co.uk/japan/poolRules.shtml