{"id":1288,"date":"2016-12-15T19:11:35","date_gmt":"2016-12-15T19:11:35","guid":{"rendered":"http:\/\/blogs.discovery.wisc.edu\/projects\/?p=1288"},"modified":"2016-12-15T19:11:35","modified_gmt":"2016-12-15T19:11:35","slug":"entry-7-creating-my-first-flock-composition","status":"publish","type":"post","link":"https:\/\/blogs.discovery.wisc.edu\/projects\/2016\/12\/15\/entry-7-creating-my-first-flock-composition\/","title":{"rendered":"Entry 7 &#8211; Creating my first Flock composition"},"content":{"rendered":"<p>Having learned the theoretical background behind flock algorithms in processing, it is time to compose a sketch.<\/p>\n<p>My idea for this sketch was to introduce a little variation from the typical flock algorithm. I wanted there to be a competition between two classes of Agents, the regular agents and another class I decided to call Enemies.<\/p>\n<p>First, there is an additional class called Enemies which uses the inheritance feature of OOP to acquire and expand the capabilities of the regular Agent class:<\/p>\n<p><a href=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-5.png\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-1290\" src=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-5-300x121.png\" alt=\"diagram-5\" width=\"300\" height=\"121\" srcset=\"https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-5-300x121.png 300w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-5-768x311.png 768w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-5-500x202.png 500w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-5.png 875w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The separation, alignment and cohesion behaviors follow the same guidelines as explained in my previous entry. But the agent class carries \u00a0the addition of a repel method in charge of creating repelling steering of the agents from the enemies:<\/p>\n<p><a href=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-4.png\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-1289\" src=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-4-300x121.png\" alt=\"diagram-4\" width=\"300\" height=\"121\" srcset=\"https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-4-300x121.png 300w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-4-768x310.png 768w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-4-500x202.png 500w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-4.png 908w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>By having this function take on a different range parameter, I can tailor how close an object has to be to another based on the type. For example, I can have the enemies have a greater influence against the agents along a larger distance. I can also use it to introduce a repel force among the enemies themselves<\/p>\n<p>Finally, I must call on all the functionality of the agents and enemies and apply the repelling method accordingly:<\/p>\n<p><a href=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-6.png\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-1291\" src=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-6-300x173.png\" alt=\"diagram-6\" width=\"300\" height=\"173\" srcset=\"https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-6-300x173.png 300w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-6-768x444.png 768w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-6-500x289.png 500w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-6.png 919w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The result is really organic. With the red and green colors, even though we are technically seeing a war between organisms, the forms that are visualized kinda almost give a Christmas feeling.<\/p>\n<p><a href=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/2039.jpg\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-1295\" src=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/2039-300x300.jpg\" alt=\"2039\" width=\"300\" height=\"300\" srcset=\"https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/2039-300x300.jpg 300w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/2039-150x150.jpg 150w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/2039-768x768.jpg 768w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/2039.jpg 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a> <a href=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/1317.jpg\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-1293\" src=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/1317-300x300.jpg\" alt=\"1317\" width=\"300\" height=\"300\" srcset=\"https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/1317-300x300.jpg 300w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/1317-150x150.jpg 150w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/1317-768x768.jpg 768w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/1317.jpg 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>In order to automate the process of acquiring an image from the sketch, I invoked the keyPressed() method \u00a0and connected it to an image function which uses the built-in jpeg export saveFrame.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-7.png\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-1296\" src=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-7-300x119.png\" alt=\"diagram-7\" width=\"300\" height=\"119\" srcset=\"https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-7-300x119.png 300w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-7-500x199.png 500w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2016\/12\/diagram-7.png 692w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having learned the theoretical background behind flock algorithms in processing, it is time to compose a sketch. My idea for this sketch was to introduce a little variation from the typical flock algorithm. I wanted there to be a competition &hellip; <a href=\"https:\/\/blogs.discovery.wisc.edu\/projects\/2016\/12\/15\/entry-7-creating-my-first-flock-composition\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":105,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/posts\/1288"}],"collection":[{"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/users\/105"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/comments?post=1288"}],"version-history":[{"count":1,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/posts\/1288\/revisions"}],"predecessor-version":[{"id":1297,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/posts\/1288\/revisions\/1297"}],"wp:attachment":[{"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/media?parent=1288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/categories?post=1288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/tags?post=1288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}