Tentative port of code to VS2010.
Use rand() instead of random().