[Ohrrpgce] SVN: james/8798 Pathfinding now breaks ties with distance squared

Ralph Versteegen teeemcee at gmail.com
Sat Jun 3 02:23:24 PDT 2017


On 3 June 2017 at 15:50, James Paige <Bob at hamsterrepublic.com> wrote:

>
>
> On Friday, June 2, 2017, Ralph Versteegen <teeemcee at gmail.com> wrote:
>
>>
>>
>> On 3 June 2017 at 07:02, <subversion at hamsterrepublic.com> wrote:
>>
>>> james
>>> 2017-06-02 12:02:15 -0700 (Fri, 02 Jun 2017)
>>> 50
>>> Pathfinding now breaks ties with distance squared
>>> ---
>>> U   wip/pathfinding.bas
>>> U   wip/pathfinding.bi
>>
>>
>> You didn't notice that I added v_heappush and v_heappop?
>>
>>
> I noticed, but wasn't sure what to do with them.
>

OK, I'll modify the code to make use of them.
I purposefully made them almost identical to the functions of the same name
from the heapq python module. The only differences are that you can specify
a compare function, and that heappop doesn't return the item it popped,
because that's impossible (unless it was moved to a temporary location and
returned byref, I guess...)


>
>
>> Also, I didn't notice before that your cost_before_node function is
>> insane. You need to store the cost of the node in the node, not recompute
>> it constantly. That is why pathfinding is so incredibly slow.
>>
>
> Oh, yes! You are right. The A* reference article I was working from even
> told me to do that, but I totally forgot. Thanks!
>
> You know, I'll bet I had the same problem in my python A* implementation
> for Bob the Hamster Dirt Dig. That sounds like exactly the sort of thing I
> would do twice ;)
>
> ---
> James
>
>
> _______________________________________________
> Ohrrpgce mailing list
> ohrrpgce at lists.motherhamster.org
> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20170603/4796ee74/attachment.htm>


More information about the Ohrrpgce mailing list