summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/random.cc
Commit message (Collapse)AuthorAgeFilesLines
* Rename a variable (decimal_chance())reaverb2014-08-111-2/+2
|
* Restore div_round_up()Nicholas Feinberg2014-07-281-0/+5
| | | | | | I hadn't thought to check if it was actually *defined* in random.cc, so of course it was not. For five years, declared in random.h and defined in stuff.cc.
* Refactor bernoulli a bit.Neil Moore2014-07-041-1/+1
| | | | | Implement bernoulli in terms of decimal_chance, and change one trivial bernoulli call (ntrials = 1.0) into a direct decimal_chance call.
* Remove an unused and bizarre functionNicholas Feinberg2014-07-011-13/+0
|
* Deduplicate some code.Neil Moore2014-06-261-16/+9
|
* Chance function(void) to function()reaverb2014-05-241-1/+1
|
* Rename percent_chance() decimal_chance() (|amethyst)reaverb2014-05-181-1/+1
|
* New function: percent_chance()reaverb2014-05-101-0/+5
| | | | | | | Designed to make sure things like no god protecting you from miscasts won't happen again. Lua could use it in a couple places, if the function was made accessible from that environment.
* Remove 3 useless functions (|amethyst)reaverb2014-05-101-25/+0
|
* Staticify (_random_real_inc)reaverb2014-05-101-2/+2
|
* Staticify (_random_real_avg)reaverb2014-05-101-2/+2
|
* Fix ui_random() using the main random generator.Adam Borowski2013-12-011-1/+1
|
* More formatting fixes for return (...);Neil Moore2013-11-151-7/+7
|
* Drop unnecessary parentheses from return statements.Adam Borowski2013-11-151-9/+9
|
* Refactor additional messages for new monsters spawning.Adam Borowski2013-10-271-0/+24
| | | | | | | | | | | | | | | | | | Not sure why do we need both these and "comes into view". This includes simplification of: * shoving the player out of stairs * "wandering" monsters spawning on the stairs * fancy messages for in-LOS abyss spawns For the last part, they had really obscure probabilities, this commit makes them easier to read. Also, it avoid mallocs and RNG calls, but that's a rather negligible optimization. This commit eliminates a mysterious call to viewwindow() as well. A comment claimed that "Special case: must update the view for monsters created in player LOS." yet this was not done for band members. It appears removing that call has no ill effects, but I might have missed something.
* s/random3/ui_random/Adam Borowski2013-10-061-1/+1
| | | | Blame SamB for the name! It's all his fault.
* random3(), with a different RNG state.Adam Borowski2013-10-061-0/+18
| | | | | | Works same as random2(). Also, stops valgrind from kvetching about unfreed asg state.
* Don't wrap low-level RNG calls twice.Adam Borowski2013-10-061-5/+47
| | | | | random.cc wrapped rng.cc, rng.cc wrapped asg.cc. The middle level did nothing but pass calls as-is.
* Increase enchantment on weapon randarts.elliptic2013-08-261-0/+13
| | | | | | | It was generally agreed that weapon randarts are a bit weaker than non-weapon randarts on average. This commit buffs them by increasing their accuracy and damage enchantment by about 3 each on average (while maintaining the same [-6,+12] range of possibilities).
* Add new random functions random_real_inc, random_real_avg, random_range_realPete Hurst2013-06-231-0/+25
| | | | | | | | | | | | | | random_real_inc Returns a value [0..1]. random_real() was not inclusive of 1.0. random_real_avg Returns a real value taking the average of a given number of rolls. random_range_real Returns a real value in a given range (with optional number of rolls).
* Drop a bunch of useless uses of this->Adam Borowski2012-07-101-1/+1
| | | | | I left a few cases where it helps disambiguate between global and object functions by the same name (formatted_string::cprintf(), etc).
* Remove parentheses around return (simple_function_call).Adam Borowski2012-07-051-2/+2
| | | | For way too paranoid and underinclusive values of "simple".
* Drop parentheses around scalar values in "return".Adam Borowski2012-07-051-17/+17
|
* Use templates for random_choose() to eliminate the need for multiple ↵Adam Borowski2011-10-311-77/+3
| | | | definitions.
* Simplify use of random_choose() by using overloading.Adam Borowski2011-10-311-11/+39
|
* Give you.skill() a "scale" argument for partial skills, make callers use it.Adam Borowski2011-09-191-0/+11
| | | | | | | Almost all uses have been converted, the only major one is unarmed base damage. For users of raw you.skills[], hp and mp calculations have been changed as well. you.skill() doesn't actually return partial values yet.
* Document lower and upper limits of random functions.Adam Borowski2011-09-191-1/+15
| | | | It's a nightmare to have some operate x >= 0, some x > 0, some x < M, some x <= M.
* Fix the rate of felling trees depending on action speed.Adam Borowski2011-07-071-0/+16
|
* cppcheck: reduce scope of some variables.Adam Borowski2011-07-051-2/+1
| | | | This can improve readability somewhat, and can speed up debug builds.
* Merge branch 'master' into unicodeAdam Borowski2011-03-131-2/+2
|\
| * Typo.Raphael Langella2011-01-281-2/+2
| |
* | Fix tiles compilation.Adam Borowski2010-09-261-1/+0
|/ | | | | | I went the lazy way and just stuck stdint.h at the beginning, we include it from a number of basic and/or platform-dependent headers so was pulled by AppHdr.h anyway.
* Fix spacing.Robert Vollmert2010-07-291-1/+1
|
* Optimize div_rand_round() by avoiding the costly random2() call when ↵Adam Borowski2010-05-181-1/+5
| | | | unnecessary.
* random.cc: fix 'warning: "UINT32_MAX" redefined' on Mac OS XSteven Noonan2010-05-061-0/+2
| | | | | | The Mac OS X SDKs define this already. Signed-off-by: Steven Noonan <steven@uplinklabs.net>
* Make sure maybe_random2 doesn't return negative values.Robert Vollmert2010-03-051-0/+2
| | | | Fixes issue #1014.
* AC/EV changes as outlined on CDO wiki.Darshan Shaligram2010-01-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first iteration of AC/EV changes as described on http://crawl.develz.org/wiki/doku.php?id=dcss:brainstorm:misc:ac Although the distinction between heavy and light armour has been removed for the actual AC and EV calculations, the heavy/light armour distinction is still in place for skill training. Skill training is not modified in any way by this change. Change details follow, with Armour = armour skill, Dodge = Dodging skill: New total AC = base_AC * (23 + effective_armour_skill) / 23 + enchantments + modifiers Where - effective_armour_skill = armour skill + racial armour skill bonus. - enchantments = armour enchantments - modifiers = transforms, mutations, etc. affecting AC. New guaranteed damage reduction: = body_base_AC*(13+Armour)/17 * max_dam/100 New total EV: = 10 + size + (7 * Dodge * Dex) / (20 * AEVP - size) - AEVP - ASP + bonuses Where size = 2 * (medium - body_size) having: body_size be one of: tiny = 0 little = 1 small = 2 medium = 3 large = 4 big = 5 giant = 6 huge = 7 For ref: halfling = small, human = medium, ogre = large, dragon = huge AEVP (adjusted evasion penalty for armour): = body_AEVP + piece_EVP Where body_AEVP is for the body armour, calculated as: = (EVP + MAX(0, 3*EVP - Str)) * (45 - Armour) /45 where EVP = base evasion penalty of the armour piece_EVP is the sum of the base evasion penalties of the non-body armour worn, excluding shields. Currently this is only applicable to bardings (EVP of 2). ASP (adjusted shield evasion penalty): = SP - (1 + Shields) / (2 * (5 + size)) where SP = 1 for buckler, 3 for shield, 5 for large shield New spellcasting penalty: = 25 * (body_AEVP + ASP) - 20 - race_mod where race_mod = 25 for elven, -15 for dwarven, 15 for races in their native armour. New combat penalties: - to-hit penalty = 1d(body_AEVP) + 1d(ASP) - to-hit penalty for 1.5 hand weapons = 1d(body_AEVP) + 2d(ASP) - to-dam penalty for 1.5 hand = 1d(ASP) - base_delay is unchanged if body_AEVP is 0, otherwise: - base_delay = max(base_delay, 1d10 + 1d(body_AEVP)) - base_delay for unarmed = max(base_delay, 1d10 + 2d(body_AEVP)) - final_delay += min(1d(body_AEVP), 1d(body_AEVP)) - final_delay for 1.5 hand += min(1d(body_AEVP) + 1dASP, 1d(body_AEVP) + 1dASP) 1.5-hand weapons now receive penalties when wearing shields, whereas before they had bonuses handed out when *not* wearing shields. To compensate for this, more or less, I've changed existing hand-and-halfer stats as follows (dam/hit/attack delay): - katana 13/2/13 -> 14/3/12 - blessed katana 14/1/13 -> 15/2/12 - double sword 15/-2/16 -> 16/-1/15 - blessed dbl swd 15/-2/15 -> 16/-1/14 - broad axe 14/-2/17 -> 14/-2/16 (axes don't need help :P) - spear 6/3/12 -> 7/4/11 - trident 9/2/14 -> 10/3/13 - demon trident 13/0/14 -> 14/1/13 These changes do not match the old 1.5 hander behaviour - they make hand and halfers stronger, because the boost is to base damage, whereas the old behaviour was to boost damage after weapon skill was applied. The 1.5 hander changes will probably need to be discussed and revisited.
* Monster respawn rate reduces after 3k turns on level, respawning ends after ↵Darshan Shaligram2010-01-221-4/+2
| | | | | | | | | | | | | | 15k turns on level, monster level fuzz and super OOD rates increase with time spent beyond 3k turns on level. The four hells, Zot, and all non-LEVEL_DUNGEON areas (Pan, Abyss and friends) are not affected by these changes. Monster level fuzz can now be up to +7 levels (was +4); this also applies to monsters placed during level-generation (14% chance per monster as before). Super OODs can now be up to +26 (random2avg(27, 2); was +11). Super OOD gen only begins after over 1k turns spent on level and is still quite rare initially (1 in 500, was 1 in 5000 in 0.5). Monster fuzz chances (chance of +0-7 to monster level) increase after 3k turns from 14% to 100% after 7.8k turns. Super OOD chances increase after 3k turns from 1 in 500 (0.2%) to 100% after 12k turns.
* Make types and bounds in random2 a bit more explicit.Robert Vollmert2009-11-101-5/+7
|
* Fix compile (stdint.h needed for uint*_t).Darshan Shaligram2009-11-091-0/+1
|
* Remove the bias from random2()Stefan O'Rear2009-11-081-1/+10
| | | | | Worst case for the old version was random2(65535) == 65534, which had a 1 in 2^30 chance of being true.
* Fix a stupid bug in defer_rand::random2avgStefan O'Rear2009-11-081-2/+2
|
* A nifty new abstraction for the RNG: defer_randStefan O'Rear2009-11-081-0/+76
| | | | | | A defer_rand object stores random numbers in a resolution-independant fashion, providing interesting monotonicity guarantees. See the next patch for a good use.
* Splitting up stuff.cc.Robert Vollmert2009-10-301-0/+263
New: colour.cc, coord.cc, coordit.cc, random.cc, rng.cc.