November 23rd, 2010, 07:03
Posts: 901
Threads: 28
Joined: Oct 2008
Interesting analysis.
Personnally, I am surprised that the discrepancies are not worse. Could you please try to list results for even lower numbers, e.g. RNG (5), RNG (3) and RNG (2)? These are used a lot in the MoM and MoO games.
I am afraid that this big-scale analysis is only a forefront of much bigger problems. The problems are probably: some "flats" or "plateaus" where the RNG gives out very similar results (probably in lower ranges) / a given sequence of RNGs that is repeated (like in a Next turn process), tends to give a repeated outcome (this is a hypothesis).
an example:
I have studied the RNG problems when I tried to correct the AI mana brown-out issue. There was a RNG ( 8 ) = 1 condition for a check for every AI, if its mana is not running low. But the game gave me constantly 1-2 AIs from 4 low on mana and disbanding creatures. I lowered the RNG to RNG (6) but the problem persisted in a smaller version. I tried to re-seed RNG before every turn, to not much of an improvement again. At the end, I was forced to simply reprogram the AI to always use Alchemy when low on mana. That fixed the RNG, hehe.
There may be many more problems like that in Next-turn (or battle resolution). We just don't see them.
November 23rd, 2010, 16:12
Posts: 973
Threads: 20
Joined: Oct 2010
kyrub Wrote:There may be many more problems like that in Next-turn (or battle resolution). We just don't see them. 
There is stuff in the next-turn code that saves and restores the seed in ways I do not quite comprehend yet. I wonder if it is by design.
--I like ILSe
November 23rd, 2010, 16:38
Posts: 901
Threads: 28
Joined: Oct 2008
That makes the next turn conservative, the RNG seeds are saved. So that you cannot reload to get better results (AI not declaring war on you or a global event not happening). I disabled it in Insecticide in times of fight against RNG and I forgot to reenable it.
In next release.
December 1st, 2010, 18:08
Posts: 973
Threads: 20
Joined: Oct 2010
As an experiment I've created a mod with Catwalk's Magician types.
I've put a downloadable versions in:
WIZARDS_Vanilla_Enchanters.EXE and SAVE1_Enchanters.GAM
If you do the obvious renames (in a Vanilla version) you can play with them.
I've put in:
- all the magician names Catwalk described,
- all their abilities including working Caster 20 MP and 40 MP abilities,
- the extra type Nomad Wizards, since apparently Catwalk missed those,
- his Clerics, Priests, and Shamans,
- a save file with all these types.
As far as I can tell, everything seems to work properly.
If anyone finds a problem with it, I'd like to know....
--I like ILSe
December 2nd, 2010, 22:54
Posts: 6,457
Threads: 134
Joined: Aug 2004
Nice work! How did you solve the issue of having to give them access to all spells in a realm?
December 3rd, 2010, 01:48
Posts: 973
Threads: 20
Joined: Oct 2010
Catwalk Wrote:Nice work! How did you solve the issue of having to give them access to all spells in a realm?
Since an Enchanter has a very close bond to Nature, seeing that he can cast all Nature spells, I've changed his race into Nature.
Since he is a colored unit now, he functions within the game constraints.
--I like ILSe
December 3rd, 2010, 04:07
Posts: 6,457
Threads: 134
Joined: Aug 2004
Hmm, I'm not sure if I like giving magicians access to a whole colour each. Not completely against it either, though. Can we make them Arcane? Are there any other side effects, like XP or not being able to cast holy weapon and such on them?
December 10th, 2010, 15:06
Posts: 973
Threads: 20
Joined: Oct 2010
Catwalk Wrote:Hmm, I'm not sure if I like giving magicians access to a whole colour each. Not completely against it either, though. Can we make them Arcane? Are there any other side effects, like XP or not being able to cast holy weapon and such on them?
They don't really have access to a whole color - they don't have enough mana!
We can't make them arcane - the game can't handle arcane spellcasters - not without a code change anyway.
As far as I know there shouldn't be any side effects, at least not any side effects Torin doesn't have (Torin is susceptible to True Light, being one of the four life units).
--I like ILSe
December 12th, 2010, 21:24
Posts: 634
Threads: 13
Joined: Nov 2010
I like Serena Wrote:Well, I'm worried about random number generation in MoM as well.
If MoMâs random number generation is questionable then why donât we let the player generate random number? Every time the user makes a click the system time is captured and logged and the very low digits, say 100 nanoseconds or so are used as seeds for each addition random number to be generated with traditional deterministic algorithms. Try not to use the same seed twice. We have to estimate the number of seeds needed and the number of clicks the player is to provide in a game, but seeds can carry over from game to game as well. Hopefully there will be more clicks then needed random numbers. How accurate is system time that MoM can capture? How much delay would that cause compared to the current algorithm?
Regarding save and load cheat, I propose dealing the exact same random numbers as last time so warp creature will give same effect if repeated.
Btw, if any of you have clean data collected and really want to know if your finding is significant, then send it to me and I can do statistical analysis such as t test, ANOVA, whatever is best.
December 13th, 2010, 13:03
Posts: 973
Threads: 20
Joined: Oct 2010
WhiteMage Wrote:If MoM’s random number generation is questionable then why don’t we let the player generate random number? Every time the user makes a click the system time is captured and logged and the very low digits, say 100 nanoseconds or so are used as seeds for each addition random number to be generated with traditional deterministic algorithms. Try not to use the same seed twice. We have to estimate the number of seeds needed and the number of clicks the player is to provide in a game, but seeds can carry over from game to game as well. Hopefully there will be more clicks then needed random numbers. How accurate is system time that MoM can capture? How much delay would that cause compared to the current algorithm?
Regarding save and load cheat, I propose dealing the exact same random numbers as last time so warp creature will give same effect if repeated.
Btw, if any of you have clean data collected and really want to know if your finding is significant, then send it to me and I can do statistical analysis such as t test, ANOVA, whatever is best.
Jtm and I reverse-engineered the random algorithm.
This is the result:
Code: uint32_t seed = 0x2A57;
uint16_t MOM_RNG(uint16_t n)
{
uint16_t value = 0;
for (uint16_t cx = 9; cx > 0; --cx)
{
uint32_t newbit = ((seed ^ (seed >> 1) ^ (seed >> 2)
^ (seed >> 4) ^ (seed >> 6) ^ (seed >> 31)) & 1);
value = ((value << 1) | newbit);
seed = ((seed >> 1) | (newbit << 31));
}
if (seed == 0)
seed = 0x30BE;
uint16_t ret = (value % n) + 1;
return ret;
}
We used dosbox-heavydebug to generate a number of random samples and the function above reproduces that exactly (as expected).
Can you tell us how "well" it behaves?
Btw, when you reload, the seed it is reinitialized to the DOS clock, which ticks 18.2 times per second and is reset at midnight.
You can observe the behavior in the Game-Data section of the Tweaker.
--I like ILSe
|