{"author_name":"Dathgale","cat":"LD #11 - Minimalist - 2008","comments":[{"author_name":"DrPetter","time":"April 20, 2008 2:50 am","epoch":1208677800,"text":"I&#8217;m embarrassed to say that I don&#8217;t have a clear idea of what KD trees would be&#8230; but a simple and effective method would be to use a good old rectangular grid and store a list of occupant ID:s in each grid cell. So for each tick you start by populating the cells (constant time per entity, grid[y\/cellsize*width+x\/cellsize].occupants.pushBack(me)), then when you need to find neighbors you just step through a few of the nearby grid cells and check the occupant lists of those. If you just need very close neighbors you can take the surrounding 3&#215;3 block of cells for example.<br \/>\n This should nicely reduce the complexity from N^2 to roughly N (for all but the most clustered cases).","spam":"N"}],"epoch":1208645040,"likes":0,"metadata":{"p_key":"75190","p_author":"Dathgale","p_authorkey":"510647","p_urlkey":"111022","p_title":"Lots of AI = performance hit","p_cat":"LD #11 - Minimalist - 2008","p_event":"LD11","p_time":"1208645040","p_likes":"0","p_comments":"2","p_status":"UPD5","us_key":"510647","us_name":"Dathgale","us_username":"Dathgale","event_start":"1208476800","event_key":"87","event_name":"LD11"},"text":"<p> I woke up about an hour ago and added most of the AI to the monsters.  The only thing they don&#8217;t do yet is avoid collisions with each other, but I hardly notice it when the green squares overlap.  When I add images it may be another story, but I&#8217;ll cross that bridge when I get there.<\/p>\n <p><img src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2008\/04\/submission_screenshot_cropped_01.thumbnail.png\" align=\"middle\" height=\"350\" width=\"350\" \/><\/p>\n <p>Here is a zoomed-out view of the action.  Note the clusters that form when monsters wander near each other.  I think it looks great in motion, except that I can count the framerate on one hand when there are this many monsters in the arena.<\/p>\n <p>I&#8217;m taking a break for dinner, and when I get back, I&#8217;ll work on optimizing the AI so it doesn&#8217;t take up my entire processor (and then some).<\/p>\n \n <p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/omnihunter\/\" rel=\"tag\">Omnihunter<\/a><\/p>","time":"April 19th, 2008 5:44 pm","title":"Lots of AI = performance hit"}