<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Have PathFinder.search return index of destination goal]]></title><description><![CDATA[<p>When passing an array of goals to PathFinder.search, it would be very useful if the returned object included the index of the selected goal. This would save CPU when you need to determine the object associated with the returned path. Currently you have to search using the last room position in the path which gets messy when using a range and multiple object types.</p>
]]></description><link>http://screeps.com/forum/topic/3160/have-pathfinder-search-return-index-of-destination-goal</link><generator>RSS for Node</generator><lastBuildDate>Mon, 18 May 2026 18:57:26 GMT</lastBuildDate><atom:link href="http://screeps.com/forum/topic/3160.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Feb 2021 02:58:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Have PathFinder.search return index of destination goal on Tue, 16 Feb 2021 03:00:06 GMT]]></title><description><![CDATA[<p>When passing an array of goals to PathFinder.search, it would be very useful if the returned object included the index of the selected goal. This would save CPU when you need to determine the object associated with the returned path. Currently you have to search using the last room position in the path which gets messy when using a range and multiple object types.</p>
]]></description><link>http://screeps.com/forum/post/16314</link><guid isPermaLink="true">http://screeps.com/forum/post/16314</guid><dc:creator><![CDATA[TehFiend]]></dc:creator><pubDate>Tue, 16 Feb 2021 03:00:06 GMT</pubDate></item><item><title><![CDATA[Reply to Have PathFinder.search return index of destination goal on Invalid Date]]></title><description><![CDATA[<p>I agree the addition to the return value would be nice. I never pass game objects into a pathfinder. It's always an array of destinations (range,pos) even if it's a single destination. Associating the returned path with index of the destination was straightforward in my case and not terribly cpu intensive. My wrapper then returns the index so my higher level logic knows which target was selected.</p>
<p>It get's a little hairy when the pathfinding fails but that corner case is hard no matter how you handle it.</p>
<p>If the plugin did the index tracking it would be noticeably faster only when there are large number of destinations (&gt;100 i'd guess, but for sure &gt;10). Changing the plugin is a tall order.</p>
]]></description><link>http://screeps.com/forum/post/16320</link><guid isPermaLink="true">http://screeps.com/forum/post/16320</guid><dc:creator><![CDATA[deft-code]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Have PathFinder.search return index of destination goal on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/49">@deft-code</a> In my case I'm using pathfinder to find the closest damaged/missing road position by travel distance using range of 3 so there's a lot of wasted CPU since there's often hundreds of goals to filter by range using the path's final position. I've figured out some tricks to mitigate the CPU usage but getting the index from the results would just be so nice.</p>
]]></description><link>http://screeps.com/forum/post/16321</link><guid isPermaLink="true">http://screeps.com/forum/post/16321</guid><dc:creator><![CDATA[TehFiend]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Have PathFinder.search return index of destination goal on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/914">@TehFiend</a> you can use findInArea to lower cpu cost instead of iterating all roads in a room. I agree this addition to know the index of target will be useful for multiple targets search.</p>
]]></description><link>http://screeps.com/forum/post/16322</link><guid isPermaLink="true">http://screeps.com/forum/post/16322</guid><dc:creator><![CDATA[U-238]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Have PathFinder.search return index of destination goal on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/2125">@u-238</a> I'm not seeing a findInArea in the API but if you're referring to lookForAtArea or findInRange I don't think that will help in this case. The room positions for all of a bunker's paths are already cached in an array which is used to check for missing / damaged roads every 1000 ticks which is pretty light on CPU. Originally I was just sorting by range but was surprised with how little CPU PathFinder uses to determine closest position by travel distance despite hundreds of goals which works a lot better when walls or swamps complicate things. Even without getting the index returned and having to do the additional search, this approach is only using around 0.06 CPU per bunker on average. Getting the index would lower this even more and reduce complexity... <img
      src="http://screeps.com/forum/plugins/nodebb-plugin-emoji/emoji/android/1f64f.png?v=a1k070tfs06"
      class="not-responsive emoji emoji-android emoji--pray"
      title=":pray:"
      alt="🙏"
    /></p>
]]></description><link>http://screeps.com/forum/post/16323</link><guid isPermaLink="true">http://screeps.com/forum/post/16323</guid><dc:creator><![CDATA[TehFiend]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Have PathFinder.search return index of destination goal on Mon, 08 Mar 2021 14:35:28 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/914">@tehfiend</a> ah yes, I was refering to <code>Room.lookForAtArea</code> (suggested that because you mentioned range of 3). agree with all your thoughts.</p>
<p>[EDIT] ah, now I got what you mean by &quot;travel distance 3&quot;, not roads in range of 3 from start pos but path to a road which ends at the range of 3 from closest</p>
]]></description><link>http://screeps.com/forum/post/16324</link><guid isPermaLink="true">http://screeps.com/forum/post/16324</guid><dc:creator><![CDATA[U-238]]></dc:creator><pubDate>Mon, 08 Mar 2021 14:35:28 GMT</pubDate></item></channel></rss>