Anonymous | Login | 2024-04-24 10:27 CEST |
Main | My View | View Issues | Change Log | Wiki | Tavern | News |
Viewing Issue Simple Details [ Jump to Notes ] [ Wiki ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||
0004107 | [DCSS] Bug Report | minor | always | 2011-06-06 20:18 | 2011-11-09 17:56 | ||
Reporter | Caethan | View Status | public | ||||
Assigned To | galehar | ||||||
Priority | normal | Resolution | done | ||||
Status | closed | Product Branch | 0.8 ancient branch | ||||
Summary | 0004107: Error in avg. spell school calculations for three-school spells. | ||||||
Description |
For spellpower calculations, twice the average skill level of all schools in the spell is calculated as part of the formula. Due to rounding errors on integer arithmetic, this average skill level is calculated incorrectly for three-school spells. This can be seen in-game using Wizard mode: set all skills to 2 and intelligence to 5 and compare the casting successes of Mephitic Cloud (a three-school level 3 spell) and any other level 3 spell, and you will see that Mephitic Cloud has a Very Poor success rate while all other level 3 spells have a Poor success rate. This is because double the average is calculated as follows: twice avg. = (2 * School 1 Skill) / (# of Schools) + (2 * School 2 Skill) / (# of Schools) + 2 * (2 * School 3 Skill) / (# of Schools) For one- and two-school spells, this formula works correctly. Because this is done using integer arithmetic, three-school spells can have rounding errors that lead to an underestimate of the average school skill. For the example I gave above, it would be: twice avg. = (2 * 2) / 3 + (2 * 2) / 3 + (2 * 2) / 3 = 4/3 + 4/3 + 4/3 = 1 + 1 + 1 = 3 The error in the code is found in spl-cast.cc, in the calc_spell_power function, in this section: unsigned int disciplines = get_spell_disciplines(spell); //jmf: evil evil evil -- exclude HOLY bit disciplines &= (~SPTYP_HOLY); int skillcount = count_bits(disciplines); if (skillcount) { for (int ndx = 0; ndx <= SPTYP_LAST_EXPONENT; ndx++) { unsigned int bit = (1 << ndx); if (disciplines & bit) power += (you.skill(spell_type2skill(bit)) * 2) / skillcount; } } This could be fixed by replacing the above code with: unsigned int disciplines = get_spell_disciplines(spell); //jmf: evil evil evil -- exclude HOLY bit disciplines &= (~SPTYP_HOLY); int skillcount = count_bits(disciplines); if (skillcount) { int tmp_power = 0; for (int ndx = 0; ndx <= SPTYP_LAST_EXPONENT; ndx++) { unsigned int bit = (1 << ndx); if (disciplines & bit) tmp_power += (you.skill(spell_type2skill(bit)) * 2); } power += tmp_power / skillcount; } |
||||||
Additional Information | |||||||
Tags | No tags attached. | ||||||
Attached Files | |||||||
|
Notes | |
(0013404) galehar (administrator) 2011-06-06 22:33 |
Wow. I can't believe such an obvious bug has been going unnoticed for so long. Fixed. Thanks! |
Mantis 1.1.8[^] Copyright © 2000 - 2009 Mantis Group |