Predator, Prey, and Obstacles
Total Page:16
File Type:pdf, Size:1020Kb
Project 05 - Predator, Prey, and Obstacles INTRODUCTION The purpose of this assignment was for us to create a simulation that uses a predator (consumer), prey (resource), and obstacles(places agents can't go). To do this, we used the design framework from project 04 but added complexity to the ways that the agents acted and interacted with each other. SOLUTION I created a simulation of Appa from Avatar the Last Airbender attempting to eat apples from trees, while avoiding deserts and annoying fire benders like Zuko. The hardest part of this project was organizing the updateState for each agent and figuring out a system for how the agents (Appa and the trees) would change state. It was very hard to balance my simulation since there were so many variables. APPA Appa, my consumer agent, changes forms depending on the number of apples in his tummy. He initializes to the landscape with 45 apples and as a category 3 (pictured furthest to the left). If he has less than 40 apples in his stomach, Appa becomes hungry and opens his mouth. If he has less than 10 apples in his stomach, Appa becomes sad and sick. If Appa has no apples in his tummy, he goes on a rebellion and leaves the landscape. If Appa has more than 100 apples in his stomach, he becomes armored Appa. If there are apple trees around him at his current location, he doesn't move and eats five apples. Otherwise, Appa attempts to move. If the location he is trying to move to is blocked by the desert agent, he stays put. If there are no obstacle in the way, he moves. If Appa is neighbors with another Appa, there is a 2% chance of making another Appa. If Appa encounters Zuko (if Zuko is one of his neighbors), and Appa is not armored, he is forced from the landscape and disappears. If Appa is armored, he forces Zuko off of the landscape. TREES The trees, my producer agent, appears on the landscape as a tree with 20 apples. The trees do not have ent powers. If a fruit tree (pictured furthest at left) has no apples, it has a 50% chance of dying (pictured at right) and a 50% chance of just becoming fruitless. If a fruit tree has 10 or fewer apples, it has a 5% chance of dying and a 5% chance of becoming a fruitless tree (pictured in middle). A fruit tree has a 2% chance of producing a new tree, which appears as a baby/fruitless tree. At each turn, a fruit tree gains an apple. A fruitless tree has a 5% chance of growing fruit again. A dead tree has a 1% chance of becoming a fruitless tree again. ZUKO Zuko randomly appears somewhere on the landscape and doesn't move and has a group of fireballs around him. If an Armored Appa approaches him, he is forced off of the landscape. Otherwise, he forces the Appa off of the landscape. He is a general pain in the butt. RESULTS + EXTENSION I learned how to use images with Graphics as an extension. I drew all of the sprites except for the Zuko mask (an image shrunken down) and the armored Appa which I modified from here. Here is one run of the simulation with 10 appas and 15 trees at the start. Here is another run of the simulation with 10 appas and 20 trees. If there are too many appas at the start..... the results are pretty terrifying. This shows 20 Appas & 20 trees. CONCLUSION I learned how to use images with the Graphics class in Java and learned a lot about organizing my ideas into code. I hope to work more with motion in the future. .