Pages

Saturday, January 21, 2012

Random is not so random

I recently read a very interesting article on random numbers I probably should have read earlier, from the aptly named random.org. I knew that computers used pseudo-random numbers before reading that, but other than that had no pre-existing knowledge. What surprised me the most though, was how not random window's default rand() function is, shown here. I wanted to see if it held true in C# too, so I quickly wrote up a quick snippet -

Bitmap bmp = new Bitmap(900, 900);
            using (Graphics g = Graphics.FromImage(bmp))
            {
                for (int y = 0; y < 900; y++)
                {
                    for (int x = 0; x < 900; x++)
                    {
                        g.DrawRectangle(new Pen(new Random().Next(2) == 0? Color.Black : Color.White), new Rectangle(x,y,1,1));
                    }
                }
            }
            bmp.Save("tmp.bmp");

The results were appalling - as you can see, there is a clearly defined pattern, not at all a desirable feature of allegedly "random" numbers. The articles I read all states that Windows by default uses a Linear Congruential Random Number Generator, with a relatively low period (I believe 32767? So max value of a signed short ^_^). Perhaps it's time to start using the Mersenne Twister for generating random numbers ye?

Edit: I am appalled by my thickness; it only dawned on me later that such a method of random generation relies on different seed values. With the tight loop I'm currently using, each new Random is initialized to the same seed value because of how close they are being created in time (apparently, this random function takes its seed value from the system clock), so that explains why many pixels in a row were the same color. This new realization prompted me to make a Random object outside of the loop and call Random.Next from a reference to that within a loop, leading to much more satisfactory results - seen here.

Monday, November 14, 2011

chinese python

Lately, I was looking at python because of it's increasing popularity, and it really shocked me to find a pure Chinese implementation. Looking at the small sample on the link, it's quite amazing, really, considering how I currently am learning Chinese as well. It never crossed my mind that programming syntax and keywords could be in another language, especially a symbolic one like Chinese. Python is quite a useful language just for general scripting, as its library includes many useful functions out-of-the-box that abstract away many tasks.


Saturday, September 3, 2011

pulse vid

aevv has kindly uploaded a vid of the latest version of pulse :]


Wednesday, August 31, 2011

sharpdevelop

recently, i've discovered another IDE for .NET called SharpDevelop.
It appears to be an open source fork of monodevelop or something. Although I'm not much of a mono person (the only place where I have any other OSes is in VMs) sharpdevelop looks a lot more promising than visual studio c# express, what I currently use. Honestly, express is a big letdown. Whenever I download solutions with c# & c++ from codeproject or the likes, it gives me "project unavailable" :\ I'm frustrated with seeing this every time I open c# express


how limited my options are! apparently, I have to pay a decent amount of money for a IDE from microsoft, visual studio 2010 professional, that integrates all the languages into one program, ironic considering how IDE stands for integrated development environment :(. sharpdevelop provides this desired integration with no lack of functionality. It has .NET 4.0 support, and a similar, if not identical winform editor, which is quite enough to satisfy me.


although granted, I think visual studio wins a bit in the UI category with its nicer looking interface


However, look at this nice choice of selections ! It's wonderful, it's free!




so yeah, sharpdevelop is a pretty good alternative if your stuck with any express edition, although i heard the asp.net support isn't that great and only the major languages have intellisense? whatever, there's always a compromise with software.


Obviously, this program is greatly reminiscent of monodevelop since it is a branch. I see it in the syntax highlighting, and some other places. Granted, monodevelop looks a little bit sleeker but I hate using the strange Gtk# gui builder thing... it just feels a lot less intuitive. Don't get me wrong, mono is amazing, being able to use .net on linux is awesome. Reflecting on that, most programmers nowadays are pretty spoiled with their fancy drag and drop GUI designers. Netbeans and its Swing designer for Java was pretty damn amazing.





subversion sucks

apparently, I really should learn how to use subversion.

exporting pulse's main repo to my own worked fairly well, but then reintegrating it back into the main was awful :( re-exported it and tried some fancy import command which worked but ended up having to upload my entire damn 100 mb folder with 50 kb/s upload speed... but the files weren't versioned so I had to re-checkout the entire repository and it turns out the old pulse code with all the songs and everything still existed so I basically downloaded another 200 mb with a shitty 150 kb/s down speed. Indeed, I can conclude that either subversion sucks or I am just that incompetent. I wonder if mercurial or git is better.

v.1

pulse is finally making more progress, aevv is back from vacation, and we've decided to call the the post-vacation version v0.1 :D

i suck




the main thing I added while aevv was gone was scoredb and some internal song cache changes
revamped song select :D
















of course, there is still much to be desired but there also is much that we have accomplished!