Javascript calculator to compare skill gains. Is it correct?


Questions, Explanations, Howtos

Mines Malingerer

Posts: 50

Joined: Tuesday, 24th December 2013, 18:44

Post Thursday, 20th March 2014, 03:54

Javascript calculator to compare skill gains. Is it correct?

Hey guys! I was reading a thread the other day about what skills to train. One thing that was discussed is what a given amount of experience would give you if you put it into another skill instead. It can get a bit confusing what with aptitudes, different skill levels, and different skill levels requiring different levels of experience.

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

Ziggurat Zagger

Posts: 11111

Joined: Friday, 8th February 2013, 12:00

Post Thursday, 20th March 2014, 04:05

Re: Javascript calculator to compare skill gains. Is it corr

Thanks a lot! I bookmarked your site.

Mines Malingerer

Posts: 50

Joined: Tuesday, 24th December 2013, 18:44

Post Thursday, 20th March 2014, 04:38

Re: Javascript calculator to compare skill gains. Is it corr

Awesome! It was actually your post in this thread that got me interested in this idea!

Tomb Titivator

Posts: 909

Joined: Thursday, 3rd January 2013, 20:32

Post Thursday, 20th March 2014, 08:25

Re: Javascript calculator to compare skill gains. Is it corr

Hey, neat, thanks for sharing! I hope some devs (or anyone familiar with the code) will weigh in to help you improve it. I'd love it if it could take cross-/anti-training into account, for one thing. For another, I've seen folks reference some sort of mechanism that makes skills take more XP the more total skill level you have, or something like that? I'd really like to be able to play around with the numbers to get a sense for how that stuff works. As is, I'm not sure this calculator is much more useful than the rule of thumb I already have: that low-level skills are much cheaper to advance than high-level skills.
Wins (Does not include my GrEE^Veh 15-runer...stupid experimental branch)

Ziggurat Zagger

Posts: 11111

Joined: Friday, 8th February 2013, 12:00

Post Thursday, 20th March 2014, 12:10

Re: Javascript calculator to compare skill gains. Is it corr

tedric,

The tool is very useful as is, you should ignore "some sort of mechanism that makes skills take more XP the more total skill level you have" when choosing what to train.
User avatar

Vestibule Violator

Posts: 1509

Joined: Wednesday, 21st September 2011, 01:10

Location: St. John's, NL, Canada

Post Thursday, 20th March 2014, 19:06

Re: Javascript calculator to compare skill gains. Is it corr

As I understand it the XP penalty makes each enemy worth less XP to you, for the purposes of skills -- it treats all skills equally that way. So 15 shields at -2 would always be the XP for X summonings at 0, whether you have 0 fighting or 27 fighting.

Thanks for the tool. You shouldn't have aptitudes hard-locked between -5 and +5 because of crosstraining/manuals/antitraining, etc.
Won all race/bg, unwon (online): Nem* Hep Uka
Favourites: 15-rune Trog, OgNe/OgIE/OgSu (usually Ash), Ds, Ru, SpEn, Ce of Chei, Qaz

For this message the author rchandra has received thanks:
Sandman25

Mines Malingerer

Posts: 50

Joined: Tuesday, 24th December 2013, 18:44

Post Thursday, 20th March 2014, 19:43

Re: Javascript calculator to compare skill gains. Is it corr

Very good point about crosstraining and manuals! I don't know why I didn't think of that. I have changed it to accept aptitudes between -20 and 20. I can't think of a case where your aptitude would actually be 20, but better safe than sorry.
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Thursday, 20th March 2014, 22:34

Re: Javascript calculator to compare skill gains. Is it corr

For testing, you should do some lua scripting, it's much more efficient. You can call the interpreter in wizard mode with ^T, then give exp by just type: you.gain_exp(10000). Much better than quaffing !exp. To write a script, take a look at scripts/training_simu.lua for an example. It's broken because I wrote it before I redid the whole skill system, but you might find some interesting stuff in it. You might even fix it :)
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...

For this message the author galehar has received thanks:
stickyfingers

Return to Coding

Who is online

Users browsing this forum: No registered users and 10 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.