better skill calculation

This commit is contained in:
tommy aka doge 2022-08-08 21:41:56 -04:00
parent 061d763a83
commit 1a04105afb
3 changed files with 23 additions and 12 deletions

View File

@ -20,7 +20,7 @@ function split(s,d)
end
function clearTmp()
for file in io.popen([[dir "./tmp" /b]]):lines() do os.remove('./tmp/'..file) end
for file in io.popen([[dir "./tmp" /b]]):lines() do if file then os.remove('./tmp/'..file) end end
end
commands:Add('yt',{},"wip", function(t)

View File

@ -52,26 +52,28 @@ commands:Add('skill',{},'skill <username|mention|"me"> <game> <style>', function
end
print('times:',#times)
t.message:reply('ETA: '..(math.floor(#times*3/100))..' minutes '..((#times*3)%60)..' seconds (found '..#times..' times out of '..API.MAPS[game].count..' maps)')
local i = 1
local test_a,test_b = 0,0
for _,time in next,times do
local rank = API:GetTimeRank(time.ID).Rank
local count = API:GetMapCompletionCount(time.Map,style)
local count = tonumber(API:GetMapCompletionCount(time.Map,style))
time.Points = API:CalculatePoint(rank,count)
time.Rank = rank
time.MapCompletionCount = count
time.Skill = API:FormatSkill(1-((rank-1)/tonumber(count)))
time.SkillRaw = 1-((rank-1)/tonumber(count))
i=i+1
time.Skill = API:FormatSkill((count-rank)/(count-1))
time.SkillRaw = (count-rank)/(count-1)
test_a=test_a+(count-rank)
test_b=test_b+(count-1)
end
table.sort(times,function(t1,t2)
return t1.SkillRaw<t2.SkillRaw
end)
local average = 0
local points = 0
for _,time in next,times do
local skill = time.SkillRaw
average = average+skill
points = points+time.Points
end
average = average/#times
local msg = 'Average Skill: '..API:FormatSkill(average)..'\n'
local msg = 'Average Skill: '..API:FormatSkill((test_a+1)/(test_b-1))..'\n'..
'Points: '..points..'\n'
for _,time in next,times do
-- msg = msg..'['..time.Rank..'/'..time.MapCompletionCount..'] '..time.Map..' ('..time.Skill..')\n'
msg = msg..API.MAPS[game][time.Map].DisplayName..' ('..time.Map..'): '..time.Skill..' for '..time.Rank..'/'..time.MapCompletionCount..' with '..API:FormatTime(time.Time)..'\n'

View File

@ -7,6 +7,8 @@ local ROVER_API_URL = 'https://verify.eryn.io/api/'
local ROBLOX_API_URL = 'https://users.roblox.com/v1/'
local ROBLOX_API_URL2 = 'https://api.roblox.com/'
local RANK_CONSTANT = 0.5
local t=tostring
local r=function(n,nd) return tonumber(string.format('%.' .. (nd or 0) .. 'f', n)) end
@ -149,10 +151,17 @@ function API:GetMapCompletionCount(MAP_ID,STYLE_ID)
if not MAP_ID or not STYLE_ID then return 'empty id' end
local _,headers = API:GetMapTimes(MAP_ID,STYLE_ID)
local pages = headers['Pagination-Count']
local res = API:GetMapTimes(MAP_ID,STYLE_ID,pages)
local res,h = API:GetMapTimes(MAP_ID,STYLE_ID,pages)
if not res then
table.foreach(h,print)
end
return ((pages-1)*200)+#res
end
function API:CalculatePoint(rank,count)
return RANK_CONSTANT*(math.exp(RANK_CONSTANT)-1)/(1-math.exp(math.max(-700, -RANK_CONSTANT*count)))*math.exp(math.max(-700, -RANK_CONSTANT*rank))+(1-RANK_CONSTANT)*(1+2*(count-rank))/(count*count)
end
-- [[ ROBLOX / ROVER AND OTHER APIs ]] --
function API:GetRobloxInfoFromUserId(USER_ID)