math.random is in LuaJIT and is much more random than love.math.random. Maybe also faster
Random Generation map error on Mobile
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Random Generation map error on Mobile
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Random Generation map error on Mobile
Not really.darkfrei wrote: ↑Wed Aug 17, 2022 12:22 pmmath.random is in LuaJIT and is much more random than love.math.random. Maybe also faster
First off, math.random exists in all kinds of lua, not just luaJIT; second, the math.random of luaJIT specifically uses one kind of pseudo-random generator algorithm, that should be consistent regardless of platform (similarly with löve's own PRNG implementation). Löve's own uses a different algorithm.
Neither is "more random" than the other. Speed differences really shouldn't matter. The only big noticeable difference is that luaJIT's math.random is not initially seeded, so you'll probably always get the same run of values unless you call the seeding function yourself.
The only one that would be bad is the regular lua one that uses some OS PRNG, which can be bad... but no official löve release uses vanilla lua anyway so that's irrelevant.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Random Generation map error on Mobile
Löve's random number generator uses FFI to allow it to be compiled. It's not all that clear which one is faster once JIT-compiled; I know Löve's one is damn fast. If LuaJIT's is more random, as you claim, it's probably because it spends more time generating better quality numbers, which means it will be slower. Nowadays most generators try to find a balance between quality, speed, memory and clarity, with some giving more weight to certain choices and others choosing differently.
Re: Random Generation map error on Mobile
For desktop, there's absolutely no difference. On some mobile devices there's no difference. It will only be different if the mobile device in question has a "notch" in the screen - a part of the rectangular screen that can't be drawn to.owowow wrote: ↑Tue Aug 16, 2022 6:47 pm And anyone knows if thats better use love.window.getSafeArea( ) instead of love.graphics.getWidth()/Height()?
Code: Select all
safex, safey, safew, safeh = love.window.getSafeArea( ) screensizex=safew screensizey=safeh
Personally, I use love.graphics.getWidth()/Height() when it comes to rendering the background, and love.window.getSafeArea() for any foreground stuff. That way you don't end up with black bars anywhere (or whatever you set the default color to), but the controls etc are guaranteed to be visible & accessible.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Re: Random Generation map error on Mobile
Thanks all, I didn't expect that much people reacted to math.randam... After I changed it to love.math.random, it doesn't show the difference but it would be nice to know when the code went complicated.
About getSafeArea(), the main target is on mobile so I will have to take into consideration in the future.
About getSafeArea(), the main target is on mobile so I will have to take into consideration in the future.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests