Vous êtes sur la page 1sur 2

CSP2151 Assignment

This assignment is an extension of the Workshops you have been doing all semester. Where
appropriate, the standards set out in previous workshops should be followed and the code must make
good use of functions, structures and logical control flow.
Design and Implement an automated artillery test simulation program to compare computer algorithms
against manual targeting. Your simulation must follow the following design specification. Your
assignment submission must also include well documented (commented) source code for the
application as well as a design document outlining the basic structure of the program and pseudocode
descriptions of the algorithms involved.
The program should first offer a selection of Artillery guns to take part in the test. The Artillery
data should be read in from a file (artillery.boom) and stored in a linked list of Artillery
structures(See Workshop 4 for the specification for this structure).
The program should then offer a selection of Projectiles to take part in the test. The Projectiles
should also be read in from a file (projectiles.boom) and stored in a linked list of Projectile
structures(See Workshop 4 for the specification for this structure).
The program should then offer a choice to either manually enter a targetDistance or to
automatically generate a targetDistance at random. This targetDistance must be less than the
maximum range of the selected Artillery and greater than the
Remember:
minimum range of the selected Artillery (use loops to ensure
You can get a random number from 1 to using:
that users cant type invalid values). You can calculate the max
(rand()%+1);
and minimum ranges based on the muzzleVelocity and
max/min angleOfElevation.

Next, the program should begin the simulation by allowing the


user to fire a shot. The user should be asked to input the
angleOfElevation (use loops to ensure that users cant type
invalid values). The path of the projectile should be calculated and
values printed to the screen showing the distance and height
of the projectile. After the shot is complete, the totalDistance,
flightTime and maxHeight reached should be printed to the
screen.
After the user has fired a shot, the AI targeting system should fire
a shot automatically. Assume the AI system has no knowledge of
the targets location and will try to guess the correct
angleOfElevation.

NOTES: To use rand successfully, follow


these guidelines:
You must use the #include <stdlib.h>
if you want to use the rand() function
You must use the #include <time.h>
if you want to draw a seed from the clock
The first line after declarations should be a call to
srand(<seed>);
You must provide the seed somehow or if you
want to draw your seed from the clock use
srand ((unsigned)time( NULL ));

The simulation should continue to repeat until either the user or the AI targeting system has hit the
target (within the blast radius of the projectile). The AI targeting system should attempt to refine its
shots in order to hit the target. (hint: Use a modified binary search).

Once the simulation is complete print the following information to a file named artillery.save
Winner: (AI Targeting unit or Human)
Total distance of winning shot:
Total flight time of winning shot:
Max height of winning shot:
Quantity of ammunition used:
Any of the following may be worth bonus marks:
1) Use your physics knowledge to incorporate drag and wind speed into your
calculations.
2) Provide a choice of several different AI Targeting methods (linear targeting, binary
search, bogo targeting etc.)
3) Any other addition to the program that improves its usefulness (Check with your
tutor first)
NOTE: The Workshops have been working up to this point to provide you with a base program of your
own work that should give you the best possible opportunity for completing this assignment. You should
look to how these Workshops have developed your work for a guide on how to structure your final
assessment.

Marking Guide:
Design

/5

Program meets requirements as stated including appropriate AI

/5

Appropriate use of functions and abstraction

/5

Correct use of data structures (structs, linked lists, etc)

/5

Code is written legibly (formatting, comments, etc)

/3

Program compiles and runs correctly

/5

Output is neat and formatted

/2

Bonus

/5

Total:

/30

Vous aimerez peut-être aussi