{"id":224,"date":"2011-09-25T02:26:54","date_gmt":"2011-09-25T09:26:54","guid":{"rendered":"http:\/\/blogs.unsw.edu.au\/infs1609\/?p=224"},"modified":"2011-09-25T02:26:54","modified_gmt":"2011-09-25T09:26:54","slug":"tutorial-week-10","status":"publish","type":"post","link":"https:\/\/blogs.unsw.edu.au\/infs1609\/blog\/2011\/09\/tutorial-week-10\/","title":{"rendered":"Tutorial &#8211; Week 10"},"content":{"rendered":"<p>The following exercises are taken from chapter 10 of the textbook. Exercises 1 &#8211; 7 explore the simulation so that you become familiar with how it works and with the Java code. The most important exercises to complete for this week are exercises 8 and 9, so don&#8217;t spend too long on the earlier ones so that you can get onto creating your own class hierarchy.<\/p>\n<p><strong>Exercise 1<\/strong> Open the <a href=\"http:\/\/www.cse.unsw.edu.au\/~is1609\/11s2\/tuts\/foxes-and-rabbits-v1.zip\">foxes-and-rabbits-v1<\/a> project. Create a <strong>Simulator<\/strong> object using the constructor without parameters and you should see the initial state of the simulation. The more numerous rectangles represent the rabbits. Does the number of foxes change if you call the <strong>simulateOneStep<\/strong> just once?<\/p>\n<p><strong>Exercise 2<\/strong> Does the number of foxes change on every step? What natural processes do you think we are modelling that cause the number of foxes to increase or decrease?<\/p>\n<p><strong>Exercise 3<\/strong> Call the <strong>simulate<\/strong> method to run the simulation continuously for a significant number of steps, say 50 or 100. Do the numbers of foxes ad rabbits increase or decrease? You can use the <strong>runLongSimulation<\/strong> to see what happens over a long time.<\/p>\n<p><strong>Exercise 4<\/strong> Use the <strong>reset<\/strong> method to create a new starting state and try running the simulation again. Is the simulation identical? If not, are there any similarities between runs?<\/p>\n<p><strong>Exercise 5<\/strong> After having run the simulation for a while, reset it and also call the static <strong>reset<\/strong> method in the <strong>Randomizer<\/strong> class. Now run the first few steps again and you should see the original simulation repeated. Take a look at the code of the <strong>Randomizer<\/strong> class to see if you can work out why this might be. You might need to look at the API for the <strong>java.util. Random<\/strong> class to help you with this.<\/p>\n<p><strong>Exercise 6<\/strong> Check that setting the <strong>userShared<\/strong> field on <strong>Randomizer<\/strong> to <strong>false<\/strong> breaks the repeatability of the simulations. Be sure to restore it to <strong>true<\/strong> afterwards because repeatability will be an important element in later testing.<\/p>\n<p><strong>Exercise 7 <\/strong>Experiment with different combinations of settings (breeding age, maximum age, breeding probability, litter size, etc) for foxes and rabbits. Do species always disappear completely in some configurations? Are there configurations that are stable?<\/p>\n<p><strong>Exercise 8<\/strong> Identify the similarities and differences between the <strong>Fox<\/strong> and <strong>Rabbit<\/strong> classes. Make separate lists of the fields, methods and constructors and distinguish between the class variables (static fields) and instance variables.<\/p>\n<p><strong>Exercise 9<\/strong> Create the <strong>Animal<\/strong> superclass in your version of the project. Ensure that the simulation works in a similar manner as before. You should be able to check this by having old and new versions of the project open side-by-side, making identical calls on <strong>Simulator<\/strong> objects in both, expecting identical outcomes.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following exercises are taken from chapter 10 of the textbook. Exercises 1 &#8211; 7 explore the simulation so that you become familiar with how it works and with the Java code. The most important exercises to complete for this week are exercises 8 and 9, so don&#8217;t spend too long on the earlier ones [&hellip;]<\/p>\n","protected":false},"author":328,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[236],"tags":[],"class_list":["post-224","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/users\/328"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/comments?post=224"}],"version-history":[{"count":1,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/224\/revisions"}],"predecessor-version":[{"id":225,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/224\/revisions\/225"}],"wp:attachment":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/media?parent=224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/categories?post=224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/tags?post=224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}