Assignment 2 – Phase 2
1. Overview of the Assignment
1.1 Learning objectives
By doing this assignment you will learn how to:
Copyright By PowCoder代写 加微信 powcoder
• Drawing using Graphics2D and geom’s shape objects (Phase 1)
• Handle collisions between objects using Shape/Area objects (Phase 2)
• Search for an item within a collection using linear search algorithm (Phase 2)
1.2. Programming Requirements
Phase 2 requirements
You will continue working on your simulation from Assignment 2 Phase 1.
1) Enlarge your environment, making its size no less than 1200X800 to accommodate collections of creature and food, while maintaining a margin to the panel edges no less than 50 on each side (Please note adjustment to margin size).
2) Create several creatures (5 ~ 8 to be desirable) and place them into an ArrayList. These creatures should be of different sizes (randomly generated, within certain range – test to find the desired size range for your own right), and have randomized colors for body or certain feature e.g. stripes.
3) Each of the creatures starts at a random location within the environment. Their motion must involve with moving along angular direction, and always facing its moving direction (as required in A2P1).
4) To make your creature smarter than phase 1, incorporate a model for your creature to pursue a “desired food” that has the largest “attraction force coefficient” (afc). The attraction force should be proportional to food size and diminish with distance, so afc = food_size/distance (please note “/” is a division sign). So each of the creatures willalways head for its desired food, and ignore the rest. It will turn to the next desired food only when the desired food is gone – either eaten by the creature itself or by other creature approaching faster to it.*
5) The food collection should be no less than 3 times of the number of creatures, which are randomly scattered within the environment. When a food is identified as a desired food by any of the creatures, it should turn into the creature’s body or certain feature’s (e.g. stripes) color to signal that.
6) Whenever a food is eaten, respawn another one with random size and random location within the environment.
7) When two different sized creatures collide, the smaller one has to turn away (i.e. change the direction by an appropriate angle in which it is moving) for an interval of 1 to 4 seconds (test to find the desired interval that works best for you so that the effect (i.e. turning and resuming) is obvious to be observed. Again employ a custom timer to count and then resume pursing its desired food again, while the larger one keeps its moving in its direction. This way the large creature can “push aside” smaller ones when pursuing the same food source.*
* Please note: For collision of creature vs. creature or creature vs. food, it must be done by way of intersecting between their outlines and dynamic bounding boxes, which involves with Area class and non-drawing transformations. Using old static bounding box approach will get 0.
8) For collision between creature and edges of the environment, it must be handled with collision avoidance using the force model (as covered in week 6), i.e. identify the potential collision preemptively and avoid the collision gracefully, rather than bump into it before turning away.
BONUS (up to 2 pts): (Please note: if you have bonus features implemented, you must notify your TA by providing a comment to specify at the top of the panel class, or you may
lose the bonus credit due to without notice by the TA)
• Change the model of collision for creatures into collision avoidance, so that smaller creatures would be able to detect possible collision with a larger one preemptively and avoid the collision rather than bumping into it. And then rather than turning away for a little while and still pursuing its desired food, it will head for its 2nd desired food instead (up to 2pts).**
** Please note in order for the actions to be sensible and cohesive, you need to implement both features to qualify for the bonus points
2. Submission and Grading Instructions
2.1 Phase 2 (14 pts)
• The project must be named (in Eclipse) with the following format LabNumber_FirstName_LastName_AssignmentNumber _PhaseNumer_StudentNumber, e.g. D104_Jim_Silvester_Assignment2_Phase2_1234567
• For the code the entire project MUST be submitted (not just the source files)
• To submit, export the project (including all the libraries used) into a zip file (Archive
File) and name it exactly the same as the project name
(Please note failure to meet any of these submission requirements above would
result in a penalty of 0.25 pt each)
• No late submission will be accepted. If you do not complete the assignment by the deadline, you will receive 0. For a legitimate reason a late submission might be allowed pending discussion with your TA before the deadline. You may be required to provide supporting documents.
• For the coding, make sure your code is syntax error free so that it runs properly on the lab machine. You would receive 0 for the coding part if your code failed to run due to syntax errors.
You are graded on completeness, correctness, and visual style.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com