Log In  

rnd(-1) (or any negative number) seems to yield a random number from -32768 to 32767.
also rnd() seems to yield a random number between 0 and 1

not sure if those are intended features, but they surely aren't documented.

I think rnd() -> (-32768,32767) and maybe rnd(x) -> sgn(x)*rnd(abs(x)) would make more sense.

edit: plus srand() doing something to the effect of srand(time()) would be nicer than defaulting to srand(0)

P#34732 2017-01-02 08:16 ( Edited 2017-01-03 09:53)

Yes, I found this by accident... ie: I had a CRAZY bug.

P#34737 2017-01-02 11:18 ( Edited 2017-01-02 16:18)

32768 is the max value of an int in pico, so that's interesting maybe that trick will come in handy some day. Also, if you're looking for better documentation: https://neko250.github.io/pico8-api/

P#34741 2017-01-02 11:42 ( Edited 2017-01-02 16:42)

@scottyelish:
ouch!

@orangecode:
yes, that's a full 32 random bits (16 integer part + 16 mantissa) and that's definitely useful. having that on rnd() (no parameter) and rnd(x) returning a number between 0 and x (or x and 0) would be slick.

yes, I know that doc, it's nicer but not much more thorough. (at this point, maybe there's a full book that needs to be written?)

P#34751 2017-01-02 13:03 ( Edited 2017-01-02 18:03)

ultra ... I was doing something that ended up like rnd(10-level) ... which worked great until level 11 :-)

anyway, take a look ... let me know what you think:

https://www.lexaloffle.com/bbs/?tid=28402

P#34752 2017-01-02 13:14 ( Edited 2017-01-02 18:14)

The wiki intends to be more thorough than the official docs. Specifically, the API reference is intended to be a place where we can accrue detailed info on each function.

http://pico-8.wikia.com/wiki/Rnd

P#34780 2017-01-02 19:46 ( Edited 2017-01-03 00:46)

@scottyelish: had a look and commented there :)

@dddaaannn: I have a silly problem with the wiki: I just can't read that red on grey...

P#34782 2017-01-02 20:11 ( Edited 2017-01-03 01:11)

I can try to tweak the colors more. The original goal was to pick from the Pico-8 palette, and the current pick is the least offensive choice in that regard. I've seen it look worse on some monitors than others for reasons I don't understand.

(Ctrl-reload to see an update, lmkwyt.)

P#34806 2017-01-02 22:55 ( Edited 2017-01-03 04:01)

hey, that salmon/peach color looks a whole lot better, thanks! bookmarked :)

the red text here on the bbs is also hard to read but far less prominent (few people bother with a title in their post). the current top banner is painful though (red glyphs on grey)

P#34822 2017-01-03 04:53 ( Edited 2017-01-03 09:53)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-09-25 10:18 | 0.060s | 2097k | Q:33