{"author_link":"\/users\/austin-sierra","author_name":"Austin Sierra","author_uid":"austin-sierra","comments":[],"epoch":1649186486,"event":"LD50","format":"md","ldjam_node_id":290635,"likes":6,"metadata":{"p_key":"165047","p_author":"Austin Sierra","p_authorkey":"1177683","p_urlkey":"390747","p_title":"My Game Pellet and What I Learned about AI Pathfinding","p_cat":"LDJam ","p_event":"LD50","p_time":"1649186486","p_likes":"6","p_comments":"0","p_status":"WAYBACK","us_key":"1177683","us_name":"Austin Sierra","us_username":"austin-sierra","event_start":"1648857600","event_key":"110","event_name":"Ludum Dare 50"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD50","removed_author":false},"_superparent":276397,"_trust":2,"author":177683,"body":"![snakey2.png](\/\/\/raw\/316\/b2\/z\/4cc88.png)\n\nThis was my first game jam and man was it a blast. So far I've played over 50 new titles all made this weekend and that's not even an eighth of all there is to learn. Game jams are definitely a great way to learn and pick up new skills. My game Pellet was a major undertaking for me because under the hood it contained scripts I struggled to properly implement in the past, particularly A\\*, a derivative of Dijkstra's algorithm. My friend @circle (https:\/\/ldjam.com\/users\/circle) here on LDJAM I think summarized most of the ideas which I learned through practice and I wanted to make a blogpost sharing these helpful tips for any other developers out there who are struggling with, or are curious to experiment with AI Pathfinding and formulas like A*:\n\n1) Don\u2019t keep checking the path. You need to set a timer for each entity, and update the path when it hits zero. Otherwise, just let your enemies go in the \u201cwrong\u201d direction for a while.\n\n2) Not all enemies need to be pathfinding during gameplay, you can just set some of the enemies to be moving in mostly random directions and the players won\u2019t notice because they\u2019re being chased by the \u201csmart\u201d enemies.\n\n3) You can, and should, consider having shifting behavior based on proximity to the player. It\u2019s way cheaper to have your game check distance then to go through full pathfinding algorithm. You can either count the number of tiles if you\u2019re using a grid system, or use a distance formula, I like Euclidean - sqrt((x1-x2)^2+(y1-2)^2).\n\n4) Don\u2019t be afraid to use a less complex algorithm for enemies if you\u2019re strapped for time. Your player doesn\u2019t know what\u2019s going on under the hood, and so long as the illusion of enemies thinking and trying to reach you is there, it doesn\u2019t really matter how you did it.\n\nAnyway if you want to check out the game here it is!\n\nhttps:\/\/ldjam.com\/events\/ludum-dare\/50\/pellet","comments":3,"comments-timestamp":"2022-04-05T19:56:06Z","created":"2022-04-05T19:12:15Z","files":[],"files-timestamp":0,"id":290635,"love":6,"love-timestamp":"2022-04-05T19:48:11Z","meta":[],"modified":"2022-04-05T19:56:06Z","name":"My Game Pellet and What I Learned about AI Pathfinding","node-timestamp":"2022-04-05T19:24:32Z","parent":285031,"parents":[1,5,9,276397,285031],"path":"\/events\/ludum-dare\/50\/pellet\/my-game-pellet-and-what-i-learned-about-ai-pathfinding","published":"2022-04-05T19:21:26Z","scope":"public","slug":"my-game-pellet-and-what-i-learned-about-ai-pathfinding","subsubtype":"","subtype":"","type":"post","version":899221},"node_metadata":{"n_key":"290635","n_urlkey":"390747","n_parent":"285031","n_path":"\/events\/ludum-dare\/50\/pellet\/my-game-pellet-and-what-i-learned-about-ai-pathfinding","n_slug":"my-game-pellet-and-what-i-learne","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"177683","n_created":"1649185935","n_modified":"1649188566","n_version":"899221","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/50\/pellet\/my-game-pellet-and-what-i-learned-about-ai-pathfinding","text":"![snakey2.png](\/\/\/raw\/316\/b2\/z\/4cc88.png)\n\nThis was my first game jam and man was it a blast. So far I've played over 50 new titles all made this weekend and that's not even an eighth of all there is to learn. Game jams are definitely a great way to learn and pick up new skills. My game Pellet was a major undertaking for me because under the hood it contained scripts I struggled to properly implement in the past, particularly A\\*, a derivative of Dijkstra's algorithm. My friend @circle (https:\/\/ldjam.com\/users\/circle) here on LDJAM I think summarized most of the ideas which I learned through practice and I wanted to make a blogpost sharing these helpful tips for any other developers out there who are struggling with, or are curious to experiment with AI Pathfinding and formulas like A*:\n\n1) Don\u2019t keep checking the path. You need to set a timer for each entity, and update the path when it hits zero. Otherwise, just let your enemies go in the \u201cwrong\u201d direction for a while.\n\n2) Not all enemies need to be pathfinding during gameplay, you can just set some of the enemies to be moving in mostly random directions and the players won\u2019t notice because they\u2019re being chased by the \u201csmart\u201d enemies.\n\n3) You can, and should, consider having shifting behavior based on proximity to the player. It\u2019s way cheaper to have your game check distance then to go through full pathfinding algorithm. You can either count the number of tiles if you\u2019re using a grid system, or use a distance formula, I like Euclidean - sqrt((x1-x2)^2+(y1-2)^2).\n\n4) Don\u2019t be afraid to use a less complex algorithm for enemies if you\u2019re strapped for time. Your player doesn\u2019t know what\u2019s going on under the hood, and so long as the illusion of enemies thinking and trying to reach you is there, it doesn\u2019t really matter how you did it.\n\nAnyway if you want to check out the game here it is!\n\nhttps:\/\/ldjam.com\/events\/ludum-dare\/50\/pellet","title":"My Game Pellet and What I Learned about AI Pathfinding","wayback_source":[]}