» News Archives

Random Banners!

The Banner of Gloomverse will not randomly switch between characters! I only have a few set up, but I think people will like the change!

Currently, its Wallis, Harold, Mooching Hobo, and Assistant. Enjoy!

posted by Loverofpiggies @ January 9th, 2012, 10:35 am  -  4 Comments


Reader Comments:



 

They seem to repeat like, 3-4 times and were really random. I didn't see a lot of walis in the times I just F5'd my laptop. Maybe you were going for that, I don't know.

posted by Pizzaman_Colors, January 10th, 2012, 12:30 am





 

Naw they really are random, but with such a small amount of images to pick from it will repeat certain images more often by accident. I've had occassions where I never see M.H. but see lots of Wallis.

posted by Loverofpiggies, January 14th, 2012, 12:48 pm





 

Actually, when I look at the JS code I think that Wallis and Assistant are about twice as likely as M.H or Harold. In your code, if you change this line:

Math.round(Math.random()*(p-1))
to
Math.floor(Math.random()*(p))

It should be more even.

(long explanation)
Javascript Math.random() generates a random real number between 0 and 0.99 inclusive, which the script then multiplies by the number of images minus 1 -- in this case 3, so it's a random real between 0 and 2.97 inclusive. Then it rounds it to an integer to pick an image index. But since it uses round and not floor, the following happens:

0.0-0.49: Harold
0.5-1.49: Wallis
1.5-2.49: Assistant
2.5-2.97: Hobo

With my fix it would be even like we would expect.

posted by trenton_dawn, January 17th, 2012, 8:56 pm



  Oh!

Okay thank you so much, thats wonderful! It was behaving a bit odd... thanks very much trenton, you guys are lifesavers. I'll fix this as soon as I can. That is fascinating. I may come ask you again about these coding issues I get sometimes.

posted by LoP not logged in (Guest), January 18th, 2012, 3:10 pm



Post A Comment

s p o n s o r s

P A T R E O N S T U F F

If you really love what I do, please consider donating to my Patreon! Support helps keep updates coming, along with publishing, and all sorts of other neat things! Patrons receive private livestreams, along with being able to see updates early!

I work to provide my content, free of charge, but to insure the future of my work- or even just to throw a little support my way, will mean the world to me! Click the image above or below if you're interested, and thank you again!

Already have a Patreon? If you're in the 5 dollar or above tier, login to see pages a day early!

Quantcast