<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 5 June 2017 at 05:07, James Paige <span dir="ltr"><<a href="mailto:Bob@hamsterrepublic.com" target="_blank">Bob@hamsterrepublic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Sat, Jun 3, 2017 at 2:17 AM, Ralph Versteegen <span dir="ltr"><<a href="mailto:teeemcee@gmail.com" target="_blank">teeemcee@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On 3 June 2017 at 16:43, James Paige <span dir="ltr"><<a href="mailto:Bob@hamsterrepublic.com" target="_blank">Bob@hamsterrepublic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="m_5520405466214425386m_3803618439062184820h5"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 2, 2017 at 8:45 PM, Ralph Versteegen <span dir="ltr"><<a href="mailto:teeemcee@gmail.com" target="_blank">teeemcee@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_5520405466214425386m_3803618439062184820m_-6537473665954405882h5">On 3 June 2017 at 15:28, Ralph Versteegen <span dir="ltr"><<a href="mailto:teeemcee@gmail.com" target="_blank">teeemcee@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="m_5520405466214425386m_3803618439062184820m_-6537473665954405882m_-3220044825209986293gmail-">On 3 June 2017 at 07:02,  <span dir="ltr"><<a href="mailto:subversion@hamsterrepublic.com" target="_blank">subversion@hamsterrepublic.co<wbr>m</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">james<br>
2017-06-02 12:02:15 -0700 (Fri, 02 Jun 2017)<br>
50<br>
Pathfinding now breaks ties with distance squared<br>
---<br>
U   wip/pathfinding.bas<br>
U   wip/<a href="http://pathfinding.bi" rel="noreferrer" target="_blank">pathfinding.bi</a></blockquote><div><br></div></span><div>You didn't notice that I added v_heappush and v_heappop?<br><br></div><div>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.<br></div></div></div></div></blockquote><div><br></div></div></div><div>(That, and the use of v_sort, which amplifies the problem)<br><br></div><div>Also, the result of guess_cost_after_node should also be stored in the node.<br></div><div><br></div><div>Also, why did you make _pathfinder_obj a global instead of a file-local (shared) variable?<br><br></div><div>Also, you could get rid of  _pathfinder_obj altogether, by storing cost_a/cost_b from close_node_compare/open_node_c<wbr>ompare in the node as well, to avoid recomputing that too. This has its own costs, but FB does squaring using floating point and pow(), so avoiding doing that repeatedly should also be a good improvement.<br></div></div><br></div></div></blockquote></div><br></div></div></div><div class="gmail_extra">Oh, that is interesting!<br><br></div><div class="gmail_extra">So does that mean I would get better performance from A * A + B * B than I would with A ^ 2 + B ^ 2 ?<br></div></div></blockquote><div><br></div></span><div>Yes.<br></div><div>I didn't know that in FB the result of ^ is always a float, but I checked the generated assembly, as I often do.<br></div><div>GCC might have been able to optimise it away... but it's very difficult to optimise floating pointer operations because even reordering additions can change the result. (There's a gcc flag, -ffast-math to perform optimisations anyway, but we don't use it... yet)<br></div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"></div><div class="gmail_extra"><br></div><div class="gmail_extra">As for _pathfinder_obj, I had forgotten the correct syntax for a file local global... I actually not even sure now... is it DIM SHARED?</div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">I've been using EXTERN so long, the only other global stuff I could remember is my feverish fighting with global scope back in the days when the code exceeded QB's internal linker limits, and i had not discovered freelink.exe yet (or whatever it was called)<br></div></div></blockquote><div><br></div></span><div>Yes. We use DIM SHARED everywhere! I think you're thinking of COMMON, which was the QB way of defining globals. We switched from COMMON to EXTERN about 10 years ago because of a bug in an early version of FB.<br></div><div></div></div></div></div></blockquote><div><br></div></div></div><div>COMMON! That was the one! I remember moving big chunks of code into subs in other modules and globalling everything with COMMON to bypass compiler out-of memory errors, and then later having to move most of those COMMON globals into ridiculously long argument lists to get past linker out of memory errors.<br></div></div></div></div></blockquote><div><br></div><div>Oh, so that's why everything had so many arguments! I thought you just didn't like globals - but silly me, stubbornly avoiding globals would have been some kind of industry best practice, so that can't have been the reason!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div><br></div><div>And I have no dang excuse for forgetting DIM SHARED, I shoulda remembered that one. ;)<br><br></div><div>Oh, well, glad it is all moot now anywa :)<br></div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">Anyway, I feel waaay better removing _pathfinder_obj entirely. I'll implement your suggestion of caching distance squared in the nodes<br><br>---<br></div><div class="gmail_extra">James<br></div></div>
<br></span><span>______________________________<wbr>_________________<br>
Ohrrpgce mailing list<br>
<a href="mailto:ohrrpgce@lists.motherhamster.org" target="_blank">ohrrpgce@lists.motherhamster.o<wbr>rg</a><br>
<a href="http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org" rel="noreferrer" target="_blank">http://lists.motherhamster.org<wbr>/listinfo.cgi/ohrrpgce-motherh<wbr>amster.org</a><br>
<br></span></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
Ohrrpgce mailing list<br>
<a href="mailto:ohrrpgce@lists.motherhamster.org" target="_blank">ohrrpgce@lists.motherhamster.o<wbr>rg</a><br>
<a href="http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org" rel="noreferrer" target="_blank">http://lists.motherhamster.org<wbr>/listinfo.cgi/ohrrpgce-motherh<wbr>amster.org</a><br>
<br></blockquote></span></div><br></div></div>
<br>______________________________<wbr>_________________<br>
Ohrrpgce mailing list<br>
<a href="mailto:ohrrpgce@lists.motherhamster.org">ohrrpgce@lists.motherhamster.<wbr>org</a><br>
<a href="http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org" rel="noreferrer" target="_blank">http://lists.motherhamster.<wbr>org/listinfo.cgi/ohrrpgce-<wbr>motherhamster.org</a><br>
<br></blockquote></div><br></div></div>