Categories
Game Development PC Nerding

Raspberry PI and Random values

I’m developing a simple rpg game, testing it with .NET on Win and Mono on Win/Mac/Linux works perfectly. Today I decided to test it on my Arch Raspberry PI to see if it could run well on this device and the result is that the game won’t even start for some “Array out of index” exception that does not appear with other systems.
After some time debugging here and there, I found out that the Random.Next function does not behave correctly on RPi.
Running this test code:
Random r = new Random();
for (int i = 0; i<10; i++) { Console.WriteLine(r.Next(0,7)); }

on the RPi prints ten times the number seven!
This is wrong for two reasons: First obliviously it's not returning random numbers and secondly it is returning the maxValue, which should be "exclusive" and it may never be returned by the function.
So calling something like
array[random.Next(0,array.Length)]
should return a value between 0 and array.Length-1, but it returns array.Length causing my out of index exception.

I tried testing Random.Next(), Random.Next(int) and Random.NextDouble() and they all behave correctly. I dunno if this is a bug in Mono:ARM or something related to the Raspberry PI.

UPDATE: Further investigations lead me to think that the problem was actually Math.Round(double), which is called in Random.Next. I'm not sure I understood it completely but looks like it is a well know problem: Mono:ARM does not support PI's hard float OSs, causing errors while working with floating point numbers. There's a patch for that and even an official RPi Debian distro with soft float support, which I won't bother installing right now. Next time PI, next time.

UPDATE: 3 April
Found an hard float version of Mono here on official Pi forums. I tested it on a clean upgraded dist-upgraded Raspbian "wheezy" from 2013 Feb 09 image and it works, remember to expand the root filesystem through raspi-config or to uninstall unneeded packages as wheezy's root partition is 2gb only and is filled with junk stuff (at least junk for me, as I use my RPI via command line SSH). On my Arch setup for some reason it was not working, but an user reported in that thread that it works on his Arch, so I think was my fault, probably some file from my previous mono test that wasn't deleted or overwritten.

Categories
Uncategorized

Why can’t people drop the call?

This is the average call I keep getting today. The smiley represents my true facial expression during the call.

“Hello?”
“Happy birthday!”
“Thanks” 🙂
“No problem, happy birthday again!”
“Thanks again” 😐
“How many?”
“Twenty four”
“Happy birthday!”
“Thanks” :/
“So, how’s going?”
“Fine”
“Happy Birthday!”
“…” -.-‘

It’s still morning and I wasted something like two hours just hearing the same story all over again.
For my next birthday I have to remember to turn off my phone, quit Skype and possibly break my home bell push.

Thanks to everyone who just sent me a mail or a quick message.

Categories
Uncategorized

F*ck DRM!

No, I’m not talking about Sim City 5. Everyone know that EA’s DRM systems fail everytime.

This time I’m talking about Max Payne 3. I bought and downloaded it during this weekend sale and only to know that Steam had no more cd keys and the game could not be launched. Today the game finally starts from Steam but, once logged in Rockstar mandatory crap social network I can’t activate my copy because their license servers failed. I’m usually ok with DRMs, online activations and such, but when those system fail its a huge unnecessary annoyance.

The next time I buy a game, I will then download it from the bay to enjoy a DRM-free experience.