The Area Game - 2 Points
Now it's time for some game logic. You will be implementing the logic
for the Area Game. The area game is a game played by those with a keen
sense of geometry and probability (and a lot of luck). The object of the
game is to gain points by covering the most area of the game board as possible.
Here's how the game is played. There are two players, A and B. Player A
will select two points (x1, y1) and (x2, y2). Then player B (without knowing
what player A chose) will chose two points also. These points describe opposite
corners of a square.
The object is to cover as much area as possible, but there's a catch.
If the players area overlaps at all, even a single point, they both lose
the amount of area they selected. So lets look at the two moves below.
Move 1:
Player A chooses (0, 0) and (1, 1).
Player B chooses (0, 2) and (5, 5).
The two squares do not overlap, so both players earn points for their
areas.
Player A has a 1 X 1 square, so earns 1 point.
Player B has a 3 X 5 square, so earns 15 points.
Move 2:
Player A chooses (1, 4) and (7, 10).
Player B chooses (0, 0) and (5, 5).
The two squares do overlap, so both players lose points for their areas!
Player A has a 6 X 6 square, so loses 36 points.
Player B has a 5 X 5 square, so loses 25 points.
Currently, Player As score is -35, and player Bs score is -10.
Get it? Good! Now your job is to be able to take the given information
(2 sets of 2 points) and score the game.
Input Format
There will be 2 lines for each move, the first for player A, and the
second for player B.
An input line will contain 4 numbers:
x1 y1 x2 y2
x1 and y1 are the players first point.
x2 and y2 are the players second point.
A single -1 indicates the end of a move.
A double -1 indicates the end of the game.
The input file will be called jin08.txt.
Output Format
The output should detail each move, a game score summary, and announce
the winner.
Move 1:
Player A = 1 points
Player B = 15 points
Move 2
Player A = -36 points
Player B = -25 points
Game Score:
Player A = -35 points
Player B = -10 points
Player B wins.
Example
Input
0 0 1 1
0 2 5 5
-1
1 4 7 10
0 0 5 5
-1
-1
Output
Move 1:
Player A = 1 points
Player B = 15 points
Move 2
Player A = -36 points
Player B = -25 points
Game Score:
Player A = -35 points
Player B = -10 points
Player B wins.