/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Square

Username:     
Password:     
             

Forum

# 1   2007-08-31 07:49:09 Square

lionel
Member
From: Grenoble, France
Registered: 2007-07-24
Posts: 71
Website

Square

You can post here questions, comments and suggestions about the Square game application.
Everybody is welcome to propose any enhancement !

Offline

 

# 2   2007-10-10 04:26:16 Square

rondesc
New member
Registered: 2007-10-06
Posts: 5

Re: Square

As for “Square”,  YOU MADE A GREAT GAME!
I do find it is more of a game & fun when used with my patched CircleOS-1.4rm.

I think it would make for more fun and interest for all if the following was true.
Whenever the player gets a new High score the Random seed the game is started with gets changed so the game action changes and he has to work up to a new high playing with a new game pattern (sort of like a new Level). The initial seeds should themselves be a fixed “random” sequence. The games should start with a display of the number used as the initial seed, the previous high score and the high score so far on this level. This way different users can say they are on that starting screen (level) and compare scores. We need no effort to make consecutive levels harder for having to set a new overall high score to complete it and advance to the next does the job.
If the RNG is conducive (and I think it is) you could start with initseed=1 for “level 1” then for the next game incarnation (after a high Score has been set) use 2 then 3,4,5… given these starting points produce differing enough sequences.
To get things going on a some what comparable basis, I recommend the game have a minimum high score it will except for the first level; about what you would get once you’re at a level where you at least understand how to play. That might be for Square 0.1.1 about 1200; it took me a while to get that.

Offline

 

# 3   2007-10-11 18:13:24 Square

rondesc
New member
Registered: 2007-10-06
Posts: 5

Re: Square

I took a hard look at the RNG you used. Here is what I see.
The formula you use is in general OK. However in theoretical mathematics the %2147483647 plays a key role; for numbers are otherwise unbounded in a mathematicians world. If an implementation is done in 64bits or more it would be likewise. As implemented, using 32 bit registers, the numbers generated are already clipped nearly the same (all be it not quite as desirably) as would the %2147483647. Performing this modulo in addition, to the one built into the 32 operations, is effectively worthless and a waist of CPU cycles.
Upon testing the randomness of number sequences generated, it is seen that removing the modulo operation makes no difference. I have verified, (with “ENT” from www.fourmilab.ch/random ) that generated number sequences yield good figures for all the tests (Entropy, Chi-square, Mean, Monte-Carlo-Pi, Serial-Correlation) except for very poor performance on the Chi-square test, which is perhaps the most important and best predictor of generating random numbers. Examining outputs I found that the low order 8 bits after an initial couple of hundred numbers begins cycling a series of hundred or so in length.
This can be fixed like this:
  u32 g_seed;
   . . .
  u16 Square_rand (void)
  {
     g_seed = ( 1103515245 * g_seed + 12345 );
     return (g_seed>>16);
  }
This yields 16 good bits of randomness, any part of which can be used to produce different ranges of values. All of the ENT test results are quite good. By the way, with yet another trick a good random set of 32bits could be generated and without using 64 bit math.
So try it out.  I Hope you make some more games for our society.
Ron Miller (zero-8.com)

Last edited by rondesc (2007-10-11 18:14:37)

Offline

 

Board footer