Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old October 25, 2010, 07:12   #1
Chud
Adept
 
Join Date: Jun 2010
Posts: 182
Chud is on a distinguished road
Random number generation?

Is the random number generation in Angband just the standard rand() from the C library?

A couple of things make me wonder... one from cheating, yes, it's true; I copied a save file for a character with 0 HP (note: still alive...) and poisoned... and since she had only one healing option, the actions from run to run were always the same (hit, miss, hit, breathe, etc) because my (healing) action was always the same. If the seed to rand() is stored in the save file, that makes sense.

The other thing that makes me wonder is that sometimes spell failure rates seem... oddly distributed, shall we say. Like, 45% failure fails 7 times in a row. Sure, it could happen... but it makes you go "hmmm..." :-)

http://www.random.org/analysis/dilbert.jpg

Chud is offline   Reply With Quote
Old October 25, 2010, 07:30   #2
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,548
Derakon is on a distinguished road
Angband uses a custom RNG, and yes, the RNG state is saved to prevent savefile scumming. Someone did an analysis years ago comparing it to the Mersenne Twister, and it had comparable levels of randomness as far as I can recall. That said, it does seem odd how often I fail a 15% spell chance several times in a row, doesn't it?
Derakon is online now   Reply With Quote
Old October 25, 2010, 08:08   #3
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 38
Posts: 1,516
d_m is on a distinguished road
Quote:
Originally Posted by Derakon View Post
Angband uses a custom RNG, and yes, the RNG state is saved to prevent savefile scumming. Someone did an analysis years ago comparing it to the Mersenne Twister, and it had comparable levels of randomness as far as I can recall. That said, it does seem odd how often I fail a 15% spell chance several times in a row, doesn't it?
If I remember, it's cycle is shorter than Mersenne Twister, but long enough that most people aren't going to notice (particularly with all the different unpredictable things we end up doing with entropy).
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old October 25, 2010, 08:09   #4
Atarlost
Swordsman
 
Join Date: Apr 2007
Posts: 441
Atarlost is on a distinguished road
Not sure why Angband never switched to Mersenne Twister on the principle that nobody ever got fired for buying IBM.
__________________
One Ring to rule them all. One Ring to bind them.
One Ring to bring them all and in the darkness interrupt the movie.
Atarlost is offline   Reply With Quote
Old October 25, 2010, 15:47   #5
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,859
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by Derakon View Post
Angband uses a custom RNG, and yes, the RNG state is saved to prevent savefile scumming. Someone did an analysis years ago comparing it to the Mersenne Twister, and it had comparable levels of randomness as far as I can recall. That said, it does seem odd how often I fail a 15% spell chance several times in a row, doesn't it?
Angband's RNG is far far less random then MT. We could change it, but it always seemed to be part of the character of the game to me.
__________________
"Physician, heal thyself."
takkaria is offline   Reply With Quote
Old October 25, 2010, 18:00   #6
fizzix
Prophet
 
Join Date: Aug 2009
Location: Madison, Wisconsin, US
Posts: 3,001
fizzix is on a distinguished road
Quote:
Originally Posted by takkaria View Post
Angband's RNG is far far less random then MT. We could change it, but it always seemed to be part of the character of the game to me.
I think with the current display where probability of failing is shown outright, it would be better to reexamine this mindset.

For example, a lot of times I make a calculation assuming independent events. I might say, I have a 5% chance of failing, so my chances of failing twice in a row is 1 in 400. This is an acceptable risk, so I'm going to attempt to cast the spell.

Now if the probability of failing twice in a row was actually 1/100 or even 1/50, I would definitely consider another course of action.
fizzix is offline   Reply With Quote
Old October 26, 2010, 08:30   #7
Chud
Adept
 
Join Date: Jun 2010
Posts: 182
Chud is on a distinguished road
Quote:
Originally Posted by fizzix View Post
I think with the current display where probability of failing is shown outright, it would be better to reexamine this mindset.
I have to agree here -- especially given that all the hardware Angband is going to be running on these days is so much faster than the earliest versions needed to work with; implementing a computationally expensive (relatively) RNG is no longer a practical problem.

Or maybe it never was; I haven't looked at how fast the various RNG algorithms are these days--maybe this was never an issue, but in any case it can't possibly be today. And I'd really rather that a given percent chance was honestly presented in the game, if it's going to be presented at all. Bugginess to the contrary might add some character to the game, but in my opinion it's not the sort of character the game wants.
Chud is offline   Reply With Quote
Old October 26, 2010, 08:38   #8
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,859
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by Chud View Post
I have to agree here -- especially given that all the hardware Angband is going to be running on these days is so much faster than the earliest versions needed to work with; implementing a computationally expensive (relatively) RNG is no longer a practical problem.

Or maybe it never was; I haven't looked at how fast the various RNG algorithms are these days--maybe this was never an issue, but in any case it can't possibly be today. And I'd really rather that a given percent chance was honestly presented in the game, if it's going to be presented at all. Bugginess to the contrary might add some character to the game, but in my opinion it's not the sort of character the game wants.
Alright, well, does anyone actually object to making the RNG closer to random? If not, we can make it happen...
__________________
"Physician, heal thyself."
takkaria is offline   Reply With Quote
Old October 27, 2010, 21:37   #9
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by takkaria View Post
Alright, well, does anyone actually object to making the RNG closer to random? If not, we can make it happen...
How much work is it? If it's a simple drop-in replacement for z-rand.c then I'm all for it - but I wouldn't have thought this was a top priority for anybody, since z-rand.c has served us well enough for however many years. But you're the boss .... ;-)
Magnate is offline   Reply With Quote
Old October 29, 2010, 22:40   #10
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 38
Posts: 1,516
d_m is on a distinguished road
I just received permission from Pierre L'Ecuyer to use his team's WELL1024a.c implementation in Angband. It uses 1024 bits of state and should perform well for us (better than Mersenne Twister).

It will be a change that could break savefiles, however I think it should be possible to detect and update people's saved seed (which has far too few bits).

So to answer Magnate's question, it should not require too much work at all
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Increasing number of Randarts Malatar Vanilla 33 January 27, 2010 19:13
feature request - spellbook number OPTION PowerDiver Vanilla 18 July 18, 2009 19:16
Number and arrow keys Nick Vanilla 3 December 6, 2008 22:58
Where to find all the number-key maps Dawnmist Vanilla 6 March 24, 2008 20:47
Steam - What is that number after my damage dice? ekolis Variants 2 December 31, 2007 03:51


All times are GMT +1. The time now is 06:06.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.