Assignments Overview
Big picture: In the series of assignment you will create a simulation of a natural world with animals (birds, fish, insects, mammals, etc) that move, eat, die and predators that hunt them. We will finish with simulating some flocking behavior and build some smartness into the simulation. In the process, you will learn Java and object oriented programming, and get plenty of practice opportunities.
Choose a kind of animal world you will build a simulation of. As we progress, you will have to draw your animals, their predators, their food, and features of the environment.
Assignment 2
You will continue working on your simulation from Assignment 1.
You will learn how to process mouse events (adding food at mouse location), work with ArrayList (several animals, several food sources), handle between-objects collisions, improve your simulation model by incorporating forces.
A2: Phase 1 Requirements
•Add food using mouse, at the mouse-click location. You can keep increasing size of the food by clicking on the created food. Your food object should hold the size information and food drawing should reflect the food size.
Bonus (1 point): The longer you keep the mouse button pressed on teh food, the larger the food portion. This bonus point will be marked with Phase 2 and will contribute to the overall bonus point sum.
•When you Ctrl-Click on food it is removed from the list.
•You must create MouseAdapter for processing MouseEvents.
•You should be able to create several food sources at the same time. Store food objects in an ArrayList. When food is created, you add it to the list, when food is eaten, remove it from the list.
•When you animal eats all food you created, it should continue moving in a straigt line, turning at the edges of the environment.
•In Phase 1, let your animal pursue the food source that is the closest, regardless of the food size.
A2: Phase 2 Requirements
•You will continue improving your project from Phase 1
•Create several animals and place them into the ArrayList. The animals should be of different sizes (randomly generated, within certain range), have a slight variation in appearance (as required in assignment 1).
•Set animal’s maximum speed based on their size. By default, the larger the animal the slower it moves.
BONUS (2 points): Change the model to reflect a concept of an ‘ideal weight’. Animal with an ideal weight will move the fastest. Underweight and overweight animals will move progressively slower.
•Incorporate a model for selecting food your animal will pursue (aka an attraction force). The attraction force should be proportional to food size and diminish with distance (AF=FOOD_SIZE/DISTANCE)
•Incorporate an energy model for your animals.
oWhen animal moves, it loses energy at certain rate based on their size (you may need to experiment with different values).
oWhen food is consumed, it adds animal an amount of energy proportional to food size.
oWhen energy falls below certain level, draw animal as sick. Sick animal move at half of their speed. When animal walls below second threshold, they will die. Remove an animal and generate a new one.
BONUS (2 points): Change the energy model in the way that animal with energy above certain threshold will grow, which will consume some energy. As a larger animal it will start consuming more energy to move and it will move slower (or if you have implemented an ‘ideal weight’ model from above, then it will move accordingly)
•Detect conflict between animals. When two different sized animals collide, the smaller one has to change the direction in which it is moving. This way the bigger animals can “push aside” smaller ones when pursuing the same food source.
Note on bonus functionality: You must indicate in the comment at the top of the main file which bonus features you have attempted and also clearly indicate bonus functionality in the comments at the appropriate places.
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。