These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

How to calculate current SP

Author
Loup Ferru
Bond Pirates
#1 - 2012-11-24 08:39:30 UTC
Hello fellow community,

today i stand before you with a question, that bugs me the last few days.
Last week i decided to learn something new, so i looked into python and wxPython and i came up with the idea to program my own api-tool. I know there are working alternatives around, but i wanted to try something new and maybe have a more or less useful tool afterwards.

To my actual question. After mand hours of frustrating learning, trying and testing i got alot of stuff to run, i wanted to implement.
One problem i encountered was the current SP. I tried to implement it and check it against, ingame and gtkevemon. And here is where the trouble started. Some of my Characters show the correct amount and are in sync with gtkevemon. Others are off by a few hundret or thousand.
I have no clue why, that would be that way.

to the alogrithm i use:

  • i'm pulling the charsheet and the skillqueue from the api.
  • i count together all SP from the charsheet (except the skill in training)
  • for the skill in training i calculate the SP/min (convert that to SP/sec). then i take the endtime of the skill and substract now from it. Which leaves me with the time left for the training.
  • then i multiply remaining time and sp/sec and substract it from the endsp (which i pulled from API)
  • now i can make that calc every tick (second) and i get uptodate skillpoints (or so i thought)


Maybe i have some error in my drain of thought, but i can't replicate, why some results would be correct and others would be off. Or someone has a different suggestion to get to the current SP of a character.
Any help will be greatly appreciated

thanks for reading
so long
Desmont McCallock
#2 - 2012-11-24 09:07:56 UTC
You wonna take a look at: http://wiki.eve-id.net/Main_Page
Loup Ferru
Bond Pirates
#3 - 2012-11-24 09:11:57 UTC
Desmont McCallock wrote:
You wonna take a look at: http://wiki.eve-id.net/Main_Page

thanks for the reply. i already spent a great deal browsing that wiki and i used it as a major source for what the api contains and how to pull it (also got the python api tool from there, which i use to parse the data)

My question was more along my method of calculating SP and that there must be different ways, because my algortihm returns the right results only half the time
Desmont McCallock
#4 - 2012-11-24 09:51:10 UTC
Do not compare your results with what the EVE client or EVE Gate says. Those don't take into consideration the SP gained while a skill level is training. Use EVEMon as reference (I heard it works with wine now) or GtkEVEMon.
Loup Ferru
Bond Pirates
#5 - 2012-11-24 10:07:19 UTC
i try to compare it to gtkevemon. I have added 5 toons in training and 3 of them show correct (or almost correct samples, there the difference could have todo with rounding issues, but 2 of them are way off ... one about 600 and the other almost 4000 at the moment. Those keep puzzling me.

And to my question, did i make an error in the aglorithm i came up with? Or is there another way to get the currentSP?
Desmont McCallock
#6 - 2012-11-24 11:31:53 UTC  |  Edited by: Desmont McCallock
You add all skillpoints from the character sheet (and when I say all I mean all).

Then you get the currently training skill level from the queue.

You calc the characters' SP/hour or SP/min or SP/sec (it's up to you)
Then you calc the following: Subtract the endtime from UTC now and multiply it by the above SP/Hour or SP/min or SP/sec (according to the representation of the subtraction), then you subtract that from endsp .
Finally you return the max between the above calc and startsp, if the skill level is in training, or the startsp. This can be made a per sec calc function.


The above is less or more the same from what you are doing but maybe the UTC time is the secret here.
Loup Ferru
Bond Pirates
#7 - 2012-11-24 12:10:01 UTC
That is pretty much what i do atm.
During the whole calculation i use the official formular for sp/min and only when i update the UI i divide through 60 so it is appropriate for the timer ticks i use (1000 millisec = 1 sec)
Two things i don't understand is, why adding all skills together? If i do that it will count to lvls of the skill currently in training (up to the lvls already trained) twice. And what do you mean with return max? what i do after the steps of counting together all skills and calculating the sp for the current training i just add them together.

Thanks for sticking with me desmont :-)

relevant part of the calc
...
def GetCurrentSP(self,charID):
skillID = self.skillQueues[charID]['skillQueue'][0]['skillID']
spPerMin = (charPri+(charSec/2))
currentSP = 0
for skill in self.charDetails[charID]['skills']:
# if skill == skillID:
## pass
# else:
## currentSP += self.charDetails[charID]['skills'][skill]['SP']
timeUntilEnd = (self.skillQueues[charID]['skillQueue'][0]['endTime'] - time.time())/60
spSinceTrain = self.skillQueues[charID]['skillQueue'][0]['endSP'] - (timeUntilEnd * spPerMin)
currentSP += spSinceTrain
...
* charId is passed with the function call
* self.charDetails is the dict i save all the api data
* self.skillQueues holds api data for the skillqueues
* i use # to mark increments, cause i don't know how to do it in this forum :)
* i didn't paste the attrib part, cause that one works but chaPri and chaSec hold the int values for the relevant attributes
Desmont McCallock
#8 - 2012-11-24 14:31:05 UTC  |  Edited by: Desmont McCallock
The char sheet only contains the skillpoints for the already trained skill levels. So the one you are currently training has not been added already. If you look at the xml you will see the related skill with skillpoints up to the previous level.

That 'max' is the equivalent function of Python that returns the max number of a number array. You will need this in case the character has a skill level training and the calc rounds the currentsp, one sp lower than the startsp (rounding issue).

Now, because I have to run to a meeting, when I return I'll try to code what I describe in Python (although I'm a C# guy), if someone else hasn't beaten me to that till then.
Desmont McCallock
#9 - 2012-11-24 21:16:46 UTC  |  Edited by: Desmont McCallock
This is basically what the function should look like.

def GetCurrentSP(self,charID):
#static part
spPerMin = charPri+(charSec/2)
charTotalSP= 0
for skill in self.charDetails[charID]['skills']:
charTotalSP+= skill['SP']
#dynamic part
queuedSkill= self.skillQueues[charID]['skillQueue'][0]
timeUntilEnd = queuedSkill['endTime'] - datetime.utcnow()
skillInTrainingSP= queuedSkill['endSP'] - (timeUntilEnd * spPerMin * 60)
charTotalSP+= skillInTrainingSP

The upper part is quite static so you don't have to compute it on each tick.
Of course you need to implement a condition to catch the cases of a paused or empty queue.
Loup Ferru
Bond Pirates
#10 - 2012-11-25 06:06:45 UTC  |  Edited by: Loup Ferru
thank you again for your reply. i'll implement that along my algorithm and will compare the results. I'll be back and tell you about the results.

EDIT:
okay i implemented your code too
http://imgur.com/LZ0rm
here i have a screen with the current skillpoints
first is gtkevemon, second is my algorithm, third is yours

as you can see, both our values are different to what gtkevemon offers

i think i've spent enough of your and my time, with that BS, i don't care about a few hundret sp anymore Roll
Desmont McCallock
#11 - 2012-11-25 09:58:14 UTC  |  Edited by: Desmont McCallock
It looks like EVE Gate has implemented a Current Skills, SP section in the Character Sheet page, which presents the Current SP at the time of the request which is quite accurate. You can compare your results with that.

Btw the code I presented is exactly the same we use in EVEMon.

Edit: I looked into GtkEVEMon's code and what I found is that it uses a totally diff way to calc the character's total SP. It calcs itself the sp for each known skill instead of adding them from the character sheet. This may result in deviation due to rounding differences.
Further more I couldn't find any per tick function that updates the total sp of the character. Couldn't run GtkEVEMon on my machine in order to be sure though.
So the SP presented from GtkEVEMon is not a comparable value imo.
Loup Ferru
Bond Pirates
#12 - 2012-11-26 09:37:04 UTC
okay. i'll try to get evemon to run and compare it to that and i just saw the sp on the eve-gate charsheet, but to be honest, since the endtime is in the api, that is more important, so i can see how long the skill and queue will take. Maybe life is more interesting with some mysteries . Thanks for all your effort so far.