[SOLVED] Jumper exception thrown not expected

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
nyenye
Citizen
Posts: 62
Joined: Fri Dec 02, 2016 1:44 pm

[SOLVED] Jumper exception thrown not expected

Post by nyenye »

First of all I've created a new thread, because Jumper's thread isn't active since 2009...

Now the exception that I get is as follows
Screenshot from 2016-12-25 18-27-55.png
Screenshot from 2016-12-25 18-27-55.png (27.08 KiB) Viewed 5913 times
and at line 330 we find:
Screenshot from 2016-12-25 18-29-11.png
Screenshot from 2016-12-25 18-29-11.png (144.02 KiB) Viewed 5913 times
The thing is that the map that I pass on is correctly formated. See map.txt
map.txt
(1.93 KiB) Downloaded 155 times
Last edited by nyenye on Tue Dec 27, 2016 1:32 pm, edited 1 time in total.
nyenye
Citizen
Posts: 62
Joined: Fri Dec 02, 2016 1:44 pm

Re: Jumper exception thrown not expected

Post by nyenye »

Sorry about repost, but couldn't attach game.love on the same entry, dunno why though.
Attachments
game.love
(2.21 MiB) Downloaded 158 times
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: Jumper exception thrown not expected

Post by Zeliarden »

math.floor or ceil the input coordinates will fix the problem

Code: Select all

assert(startNode, ('Invalid location [%d, %d]'):format(startX, startY))
outputs the integer (12,12) value of startX, startY instead of the real value (12.5, 12.5 or something like that)
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Jumper exception thrown not expected

Post by raidho36 »

Doesn't that generates strings every time this functions is called? Because all (assert) function arguments are evaluated before it is called. That's hugely wasteful.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Jumper exception thrown not expected

Post by Positive07 »

Yes it does, assert is a really inefficient function since the string is evaluated regardless of being valid or not... I usually use simple checks

Code: Select all

if not startNode then
   error(('Invalid location [%d, %d]'):format(startX, startY), 1)
end
Which also lets you specify the start depth of the stack traceback
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
nyenye
Citizen
Posts: 62
Joined: Fri Dec 02, 2016 1:44 pm

Re: Jumper exception thrown not expected

Post by nyenye »

Thanks for the tips, I'll give it a shot. About the performance problem, I thought that Jumper was the standard library for pathfinding in Lua/Love2D. Do you have any other recomendation? Or do you make your own implementation?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Jumper exception thrown not expected

Post by raidho36 »

There's no "standard" anything in Lua, because it's a "there are many ways to do this" kind of language. But sure enough, generating strings in asserts will slow things down substantially for no reason. Not only creating an unique string is not a fast operation, but also the result is immediately discarded and becomes garbage thus contributing to runtime overhead, and all of that on top of never needing to do any of it in the first place.
nyenye
Citizen
Posts: 62
Joined: Fri Dec 02, 2016 1:44 pm

Re: Jumper exception thrown not expected

Post by nyenye »

raidho36 wrote:There's no "standard" anything in Lua...
Thanks for the info. Then do you have any "better" or different implementation for Pathfinding? Or maybe just change the code of the library to do what Positive07 said?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: [SOLVED] Jumper exception thrown not expected

Post by raidho36 »

I don't have anything in my sights, so yes you could just replace wasteful asserts with less intensive checks, or even remove them altogether since they serve no practical function and only exist to assist debugging.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests