Mines Malingerer
Posts: 50
Joined: Tuesday, 24th December 2013, 18:44
Javascript calculator to compare skill gains. Is it correct?
I have attempted to make things a bit simpler by creating a VERY rudimentary javascript calculator to do the math for you. It does not take into account experience level affecting skill gain, but the effect should be unimportant. The amount of experience points used would be the same in both cases of advancing skills so experience level should not have an impact if my reading of the source code is correct.
This is where I was hoping one or two of you could help me out - I am not at all familiar with the source code. I only spent a couple hours reading skills.cc and skills2.cc to try and understand the math. I could easily misunderstand what the source code does. I also could also have messed up the math on the javascript side. (My javascript knowledge is basically nonexistent. Everything I know about javascript was learned in making this.)
I have had a hard time testing this calculator. I've been using wizard mode and both &s (give 20,000 skill points command) and quaffing potions of experience. From what I have tried so far everything seems to work, but I could be missing something. I could easily be missing some obvious way to test it, but both &s and potions don't give enough experience at high levels to accurately test the calculator. I can give myself any number of skills levels, but that doesn't help test it.
This is a link to my own web page hosting the calculator. You could also save the code below and open it that way of course.
http://ianberrigan.com/
Thanks for your time!
- Code:
<FORM NAME = "Calc">
THIS CALCULATOR IS VERY MUCH IN BETA AND MAY BE VERY INCORRECT. TAKE ALL RESULTS WITH A LARGE GRAIN OF SALT.
<br>
<br>
This is a very rudimentary calculator for DCSS designed to show you what else you could do with the XP you spend training a skill.
<br>
<br>
Example 1: A human venom mage has found a shield of reflection. He is already using an ordinary buckler and has 5 levels of the shields skill to negate the spell casting penalty. He would have to advance shields to 15 if he wanted to wear the shield of reflection with out any penalty to spellcasting. He wants to know what else those points would get him if he put them into another category. He currently has poison magic at skill level 17 and decides to input the data to see how many levels of poison magic he could gain instead.
<br>
Aptitude of first skill = 0
<br>
Current level of first skill = 5
<br>
Proposed level of first skill = 15
<br>
Aptitude of first skill = 0
<br>
Current level of second skill = 17
<br>
Result = poison magic would gain 4 levels and advance to level 21.
<br>
<br>
Example 2: A deep elf wizard has conjurations level 20. He realizes that increasing conjurations to level 21 would take a long time and he wonders what else he could train with that experience instead. He has a good artifact long blade, but 0 levels of the long blade skill. If he put the experience it would take to advance one level in conjurations into long blades instead how many levels would he gain?
<br>
Aptitude of first skill = 1
<br>
Current level of first skill = 20
<br>
Proposed level of first skill = 21
<br>
Aptitude of first skill = -1
<br>
Current level of second skill = 0
<br>
Result = 6.6 levels would be gained.
<br>
<br>
Please note that only integer values are entered the calculator. If you enter a decimal as part of the input the fraction part of it will be ignored.
<br>
<br>
Aptitude of first skill<INPUT TYPE = "text" ID = "AptInput" Name = "AptInput" Size = "3">
Current level of first skill<INPUT TYPE = "text" ID = "CSLI" Name = "CurrentSkillLevelInput" Size = "3">
Proposed level of first skill<INPUT TYPE = "text" ID = "DSLI" Name = "DesiredSkillLevelInput" Size = "3">
<br>
Aptitude of second skill<INPUT TYPE = "text" ID = "AptInput2" Name = "AptInput2" Size = "3">
Current level of second skill<INPUT TYPE = "text" ID = "CSLI2" Name = "CurrentSkillLevelInput2" Size = "3">
<br>
<INPUT TYPE = "button" Name = "GeneratePossibilites" Value = "GO" OnClick = findSkillGain()>
<br>
<TEXTAREA ID = "Decimal" Name = "Decimal" Value = ""Cols = "50"></TEXTAREA>
<br>
<TEXTAREA ID = "Alert" Name = "Alert" Value = "" Cols = "50"></TEXTAREA>
<script>
function findSkillGain() {
var SkillPoints = new Array();
SkillPoints[0] = 0;
SkillPoints[1] = 50;
SkillPoints[2] = 150;
SkillPoints[3] = 300;
SkillPoints[4] = 500;
SkillPoints[5] = 750;
SkillPoints[6] = 1050;
SkillPoints[7] = 1400;
SkillPoints[8] = 1800;
SkillPoints[9] = 2250;
SkillPoints[10] = 2800;
SkillPoints[11] = 3450;
SkillPoints[12] = 4200;
SkillPoints[13] = 5050;
SkillPoints[14] = 6000;
SkillPoints[15] = 7050;
SkillPoints[16] = 8200;
SkillPoints[17] = 9450;
SkillPoints[18] = 10800;
SkillPoints[19] = 12300;
SkillPoints[20] = 13950;
SkillPoints[21] = 15750;
SkillPoints[22] = 17700;
SkillPoints[23] = 19800;
SkillPoints[24] = 22050;
SkillPoints[25] = 24450;
SkillPoints[26] = 27000;
SkillPoints[27] = 29750;
var Apt = parseInt(document.getElementById("AptInput").value);
var CSLI = parseInt(document.getElementById("CSLI").value);
var DSLI = parseInt(document.getElementById("DSLI").value);
var Apt2 = parseInt(document.getElementById("AptInput2").value);
var CSLI2 = parseInt(document.getElementById("CSLI2").value);
if(Apt < -5 || Apt > 5|| Apt2 < -5 || Apt2 > 5){
document.getElementById("Alert").value = "ALERT: One of the aptitude inputs is out of bounds. Aptitudes must be between 5 and 5.";
}
else if (CSLI < 0 || CSLI > 27 ||CSLI2 < 0 || CSLI2 > 27 || DSLI < 0 || DSLI > 27 ){
document.getElementById("Alert").value = "ALERT: One of the skill level inputs is out of bounds. Skill levels must be between 0 and 27.";
}
else{
document.getElementById("Alert").value = "No input errors detected.";
}
var AdjustedApt = (Apt-Apt2);
var PointDifference = SkillPoints[DSLI] - SkillPoints[CSLI];
var Multiplier = Math.pow(2, -1 * AdjustedApt/4);
var AdjustedPoints = PointDifference * Multiplier;
var i = CSLI2;
var PointCount = SkillPoints[CSLI2] + AdjustedPoints;
while(SkillPoints[i] <= PointCount ){
i++;
if(i > 27){
break;
}
}
var Remainder = 0;
var PointsToEndOfLevel = 1;
if(i > 27){
var Remainder = 0;
var PointsToEndOfLevel = 1;
}
else{
Remainder = PointCount - SkillPoints[i-1];
PointsToEndOfLevel = SkillPoints[i]- SkillPoints[i-1];
}
document.getElementById("Decimal").value = (i - 1 + Remainder/PointsToEndOfLevel).toFixed(1);
}
</script>
- For this message the author Rep Henry Clay has received thanks: 3
- billob, duvessa, Sandman25