{"id":477,"date":"2013-12-27T23:20:51","date_gmt":"2013-12-28T06:20:51","guid":{"rendered":"http:\/\/www.zombox.net\/?p=477"},"modified":"2013-12-27T23:27:26","modified_gmt":"2013-12-28T06:27:26","slug":"ai-update","status":"publish","type":"post","link":"http:\/\/www.zombox.net\/?p=477","title":{"rendered":"AI update&#8230;"},"content":{"rendered":"<p>So now that the old navgrid pathfinding system has been replaced by the new navmesh system, I&#8217;ve gone in and re-written all of the AI code for npcs and zombies.<\/p>\n<p>The old code was messy and relied on too many navgrid functions to simply adapt to the new system, so I started fresh. I&#8217;ve now unified all AI-related aspects of the zombies and NPCs (rather than have separate AI code for each), and optimized things like the flocking system and Line-of-Sight checking (using kd-trees and BVH trees, respectively). This allows the game to run faster with more zombies on screen at once.<\/p>\n<p>While the iOS version of the game will typically have around 50 zombies visible at a time max, I benchmarked the new code with 650 zombies at once and it still runs at +30fps. Keep in mind the old code could handle around 200-250 before getting too laggy. So it&#8217;s quite an improvement!<\/p>\n<p>Here&#8217;s an animated gif showing part of a group of 500 zombies crowing around the player\/environment, using the new AI system (keep in mind for illustration purposes, their attacks have been disabled):<\/p>\n<p><a href=\"http:\/\/www.zombox.net\/stuff\/zombox_cap_121.gif\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone\" src=\"http:\/\/www.zombox.net\/stuff\/zombox_122.jpg\" alt=\"\" width=\"480\" height=\"320\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So now that the old navgrid pathfinding system has been replaced by the new navmesh system, I&#8217;ve gone in and re-written all of the AI code for npcs and zombies. The old code was messy and relied on too many navgrid functions to simply adapt to the new system, so I started fresh. I&#8217;ve now [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,8,3],"tags":[],"_links":{"self":[{"href":"http:\/\/www.zombox.net\/index.php?rest_route=\/wp\/v2\/posts\/477"}],"collection":[{"href":"http:\/\/www.zombox.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zombox.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zombox.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zombox.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=477"}],"version-history":[{"count":4,"href":"http:\/\/www.zombox.net\/index.php?rest_route=\/wp\/v2\/posts\/477\/revisions"}],"predecessor-version":[{"id":481,"href":"http:\/\/www.zombox.net\/index.php?rest_route=\/wp\/v2\/posts\/477\/revisions\/481"}],"wp:attachment":[{"href":"http:\/\/www.zombox.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zombox.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=477"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zombox.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}