6.170 Laboratory in Software Engineering
Fall 2003
Final Project Amendment: Force Fields

Handout F5


Contents:


Background

The lecturer in charge of acceptance testing has enjoyed using your initial implementation. He has decided, however, that the pinball game needs to be extended. First, he wants to see how his pinball would behave if there are force fields. Second, he now wants to be able to create boards with multiple balls since he is unchallenged with only a single ball on the board. Finally, to make things more interesting, he wants to be able to specify the size and mass of each ball.

You must extend Gizmoball to support force fields built from point sources and sinks, multiple balls, and varying ball size and mass of each ball.

Multiple Balls

You must now support multiple balls. This requires no change to the file format, except that there can be multiple "Ball" commands each correponding to a new, different ball. In build mode, you must allow the user to place multiple balls on the board, and in run mode these balls must realistically interact.

Note that the behavior of the Absorber gizmo is now underspecified. You must choose how the Absorber will now behave with multiple balls on the board, and write up your decision in the Revised Specification section.

Varying Ball Mass and Size

In addition to supporting multiple balls, your Gizmoball game must also support balls of different mass and sizes. The user should be able to specify what the radius (size) and mass for each ball in build mode. These balls should interact realistically during run mode, e.g., when a small but heavy ball collides with a large but light ball, the large ball should gain more velocity than the small one.

Force Fields

Your Gizmoball game must now support user defined force field sources and sinks. Sources and sinks affect the movement of the ball. A sink attracts your ball towards the center of the force field while a source repels your ball from the center of the force field.

The equation below defines the magnitude, F, of the force field, where mb is the mass of the ball, k is the force field constant, and r is the distance between the center of the ball and the center of the force field.

Note that in the case of a sink, the ball may or may not stop at the center of the force field, depending on its momentum. Your program must be able to accurately calculate the dynamics of the various forces to determine the movement of the ball. The user should be able to specify the location of the sink/source and its magnitude during build mode. In addition, the user should be able to specify more than one source and one sink.

File Format

In order to accomodate sinks and sources, we introduce two new commands Source and Sink. The format of these commands are as follows:

          Source So1 12.0 2.4 14.3
          Sink Si1 13.4 19.2 8.2

The Source command places a source at (12.0, 2.4) with a force field constant of 14.3. Similarly, the Sink command places a sink at (23.4, 19.2) with a force field constant.

In addition, we need to modify the Ball command to add the size and mass (per unit volume) parameters. For example,


          Ball B1 14.2 4.5 -3.4 -2.3 2.1 1.5

places a ball with its center at (14.2, 4.5). The ball has an initial velocity of 3.4L/sec to the left and 2.3L/sec updward. In addition, the ball has a radius 2.1 cm and mass of 1.5 gram/cm3.

Formally, the syntax and semantics of the file format is amended as follows:

Syntax Amendment

<command> ::= ... (same as previously, except Ball) ...
	      Ball <name> <float-pair> <float-pair> <float-pair> |
              Sink <name> <floa-pairt> <float> |
              Source <name> <float-pair> <float> |

Semantics Amendment

"Sink" (IDENTIFIER name) (FLOAT x) (FLOAT y) (FLOAT k)
"Source" (IDENTIFIER name) (FLOAT x) (FLOAT y) (FLOAT k)
Creates a force field sink/source with center of the field at (x, y) and a force field constant of k. Within the file, the name must be unique.

"Ball" (IDENTIFIER name) (FLOAT x) (FLOAT y) (FLOAT vx) (FLOAT vy) (FLOAT r) (FLOAT m)
Creates a ball with center (x, y), initial velocity (vx, vy), radius r cm, and mass of m grams. Within the file, the name must be unique, and may be used later to refer to this specific ball. Note that in addition to the new format, your final implementation must still support the orignial Ball format.

Sample Boards

We provide a sample board (given in the standard file format) to illustrate two of the many possible configurations your clients expect to be able to create and play using these new features.

Ambiguities

Parts of this amendment have been left intentionally vague. It is up to you to decide what (if any) clarifications are necessary. You should include any changes to your Revised Specification documentation in your final submission on 12/8/2003.

Design Decisions

Spend some time thinking about the best way to incorporate this change into your design. In your final design write-up, be sure to discuss the changes to your initial design (and the relevant trade-offs). You will be graded on how easily your initial design can support the amendment, and how cleanly you incorporate the amendment into your design.

Hints


Back to the problem sets page.
For problems or questions regarding this page, contact: 6.170-webmaster@mit.edu.