Back to the faculty page for James Tam Return to the course web page

 

CPSC 233: Full Assignment 1

Due at 4 PM. For assignment due dates see the main grid on the course webpage.

New Concepts to be applied for the assignment

Note: it is not sufficient to just implement a working program and expect full credit. Even if you program is fully working the design is not as specified in this document (E.g. your program implements static methods other than the main method or only a single class is used) then your marks will suffer greatly. (Your raw grade point is quartered if you do these two things i.e. an 'A' becomes a 'D' grade). There are other crucial design requirements but I used two extreme examples to make a point. You are to learn and practice good Object-Oriented principles in CPSC 233 and you are expected to be able to apply these principles in higher level courses. If you want an idea of the "how not to do it" approach here is a small example that includes a static method (other than main) and you can presume it contains the entire solution for this assignment (no I am not going to post a complete solution for you) all in the definition for class HowNotToDoItManager.

Description:

Write a simple a fight simulator (in case you are not at all familiar with martial arts here's a video that not only illustrates different types of attacks but also attacks at the three different heights - JT - video link removed after the university copyright office indicated there may be issues). (In-depth martial arts knowledge is NOT mandatory to complete your assignment). Information about the simulation will take the form of text descriptions of the attacks and defenses (more on this later).

Your program will have two opponents: an attacker (that only launches attacks) and a defender (that can only defend against the attacks). There's three types of attacks categorized by height: high, medium and low. Typically you should use class constants for unchanging values (i.e., public final static int HIGH = 1;) but because this is your first Object-Oriented program this requirement is waived for this assignment, constants that are local to a particular method may be used instead).

Similar to the attacks, there's three types of defenses: high, medium and low. If the height of an attack and a defense match then the attack is blocked. Otherwise the attack is counted as a 'hit'. The simulation runs a fixed number of attack-defenses sequences (from 1 - 100 'rounds' of attacks and defenses). The user will determine the number of rounds when the simulation first runs. If a value outside the range is entered then the default number of rounds (ten) will be executed (no re-querying for a new value needed).

Attacker control: The basic version of the program will have an attacker which has an equal probability at attacking at the three heights  - you can use integer rather than real number distributions for determining the probabilities. That is, you can call the 'nextInt' method instead of the 'nextFloat' method of class Random. The advanced version will allow user input to specify the probabilities: When the program first runs, the user can also determine the proportion of attacks that originate at the three different heights (e.g., high = 50%, medium = 30%, low = 20%). These three proportions must sum to 100% otherwise the program will use the defaults (again there's an equal probability of each type of attack). Hint: you don't need to use percentages to have an even three way split between the 3 heights (image if you were able simulate the rolling of a 9 sided dice with a Java program...).

Defender control: The defender will be entirely controlled by the computer. The 'unskilled' defender has an equal chance of employing one of the three types of defenses. A program that implements an 'intelligent' defender will analyze the pattern of attacks and adjust the probability of each type of defense being employed over time. (For example if the attacker always throws high attacks then the defender will eventually extrapolate the pattern and use high defenses more frequently). It is up to you to decide how many rounds are needed before the defender begins to adjust to  the pattern of attacks. And the value determining the adjustment period can be hard-coded (fixed) into the program (no user input needed at run-time). The minimum number of rounds needed to adapt should be one (with zero attacks thrown there is no pattern to analyze). Prior to analyzing and determining the pattern of attacks the defender should have an equal probability of employing each type of defense.

Exactly what constitutes 'intelligent' for this assignment? Because this isn't a formal class in Artificial Intelligence the definition is fairly broad: as long the program demonstrates the ability to somehow adapt to the pattern of attackers and the marker can clearly see the pattern as the program executes (the display of statistics each round will be very useful for communicating this). If for instance the attacker throws only medium attacks, after the learning period is over the defender should eventually employ only medium height defenses (or at least have an extremely high probability of employing this type of defense).

You can either come up with your own algorithm for the defender or you can freely research algorithms online. In the latter case make sure you clearly cite all your sources. (Failing to list a source may be regarded as academic misconduct).

The program will tally a number of statistics and display them during each round *and* at the end of the simulation.  Here's the information that your program MUST display. To avoid having TAs waste time during marking don't deviate from what's listed here.

Statistics displayed each round: the round number, the type of attack and defense chosen, the result of the attack-defense combination (hit or block).

Statistics displayed when the program ends: the total number of successful attacks and blocks and the probabilities of each type of attack-defense at the end (the values for the attacker won't change but an intelligent defender's proportions should go from equal values to more closely reflect the proportions of the attacker).

These outputs  must not only present the needed information but must also be reasonably formatted. Real number values must display with two places of precision. The program output is even more crucial when you have implemented an intelligent defender. The marker must be able to see the effects of the defender adapting to the pattern of attacks otherwise you may not get credit for your work. The marker won't have the time to trace through your program or program output if things are not explicit in your output.

You can find a [text file] that records of the output of my program. As you will see my 'intelligent' defender is not particularly 'intelligent' but it's sufficient for CPSC 233. Note however how the defender adapts after round 20, quite dramatically in this case because the probability of attacks is 100% for one of the heights.

Program design [Click here for overview]: the program will consist of 3 Java source code files (AttackerDefenderManager). Each class definition must be in it's own file with the file name matching the class name.

Marking:

Important points to keep in mind:

  1. Due time: All assignments are due at 4 PM on the due dates listed on the course web page.  Late assignments or components of assignments will not be accepted for marking without approval for an extension beforehand. Alternate submission mechanisms (non exhaustive list of examples: email, uploads to cloud-based systems such as Google drive, time-stamps, TA memories) cannot be used as alternatives if you have forgotten to submit work or otherwise have not properly submitted into D2L. Only files submitted into D2L by the due date is what will be marked, everything else will be awarded no credit.
  2. Extensions may be granted for reasonable cases by the course instructor with the receipt of the appropriate documentation (e.g., a sworn declaration with a commissioner of oaths). Typical examples of reasonable cases for an extension include: illness or a death in the family. Example cases where extensions will not be granted include situations that are typical of student life: having multiple due dates, work commitments etc. You should mitigate the occurrence of technical problems by submitting your work early and often and early in D2L as well as performing regular backups. Do not expect to get an extension if something like this has occurred.
  3. Method of submission: You are to submit your assignment using D2L [help link]. Make sure that you [check the contents of your submitted files] (e.g., is the file okay or was it corrupted, is it the correct version etc.). It's your responsibility to do this! (Make sure that you submit your assignment with enough time before it comes due for you to do a check).
  4. Identifying information: All assignments should include contact information (full name, student ID number and tutorial section) at the very top of your program in the class where the 'main()' method resides (starting execution point). (Note other documentation is also required for most of the full assignments).
  5. Collaboration: Assignments must reflect individual work; group work is not allowed in this class nor can you copy the work of others. Students should not see each other's graded programs (don't post it, don't email it out, don't show it in a screen share). For more detailed information as to what constitutes academic misconduct (i.e., cheating) for this course please read the following [link].
  6. Execution: programs must run on the computer science network (if applicable during that particular semester) running the latest version of Java (this is what applies for the distance learning version of the course). If there libraries or classes external to what's included in Java then you must include clear and complete instructions for your marker as to exactly what needs to be done to compile and run your submission otherwise you may be awarded no credit. Also you should be wary of using external libraries rather than writing the code yourself because you may not be awarded credit for particular features if you didn't write the code yourself. If you write you code in the lab and work remotely using a remote login program such as Putty or SSH then you should be okay (assuming you don't login to a non-Linux computer). If you choose to install Java on your own computer then it is your responsibility to ensure that your program will run properly here. It's up to you if you wish use the graphical program builder to write/run your programs but if you do you submit your program in the form of text ".java" file or files.
  7. Use of pre-created  libraries: unless otherwise told you are to write the code yourself and not use any pre-created classes. For this assignment the usual acceptable functions include code in the Scanner class and methods for displaying output such as: printf()print()println(). Also for this assignment you can use the random number generating capabilities of class Random or class Math.
  8. Late submissions Make sure you give yourself enough time to complete the submission process so you don't get cut off by D2L's deadline (when you get a zero). Unlike the mini-assignments you may be able to submit your work late and be awarded some credit.

Submission received:

On time

Hours late : >0 and <=24

Hours late: >24 and <=48

Hours late: >48 and <=72

Hours late: >72 and <=96

Hours late: >96

Penalty:

None

-1 GPA

-2 GPA

-3 GPA

-4 GPA

Submission not graded.

 

Submitting your work: