Problem: Building an Attack Computer

Your task is to create the part of a game that controls and shoots a torpedo at a target from a submarine. One goal of the game is to sink targets, and you're responsible for the attack computer (AC) portion of the overall game, which achieves that goal. (The game has other goals and other components that achieve them.) Your component directs the actions of the submarine after at least one target has been identified. Your part is not responsible for avoiding becoming a target or for controlling general cruising when no target is in sight.

The game reenacts a World War II–era U.S. submarine and torpedoes of that era. The torpedoes follow preset bearings until they hit their targets or run out of fuel, at which point they sink harmlessly to the bottom of the sea. When you preset a bearing in a torpedo's gyroscope, that torpedo can take a course different from the course of the submarine that shot it.

During your research on the problem, you find that the AC must ask and answer four questions to sink a target:

  • Is there a ship that can become a target?
  • How does the submarine need to maneuver to get into shooting position?
  • Is the shooting position within the tactical limitations of the torpedo?
  • Is the solution — the geometry of the target's position, the submarine's position, and the capabilities of the torpedo — sufficient to shoot a torpedo and sink the target?

The answers to these four questions are the requirements that your part of the system ...

Get Pattern-Oriented Software Architecture For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.