Golf. Now 8161 tokens (from 8185).

This commit is contained in:
Kistaro Windrider 2023-07-23 16:08:54 -07:00
parent be0f1349ae
commit 09ef3617f7
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -1960,30 +1960,25 @@ function readdata()
end end
function getscores(mode) function getscores(mode)
mode-=1 mode *= 3
local scores={} return {
for i=1,3 do dget(13+mode),
scores[i]=dget(15+3*mode+i) dget(14+mode),
end dget(15+mode)
return scores }
end end
function addscore(mode,score) function addscore(mode,score)
if (score==0)return -1 if (score==0)return
local s=getscores(mode) local s,inv=getscores(mode), invscr_ordering and -1 or 1
s[4]=score s[4]=score
if(invscr_ordering)inv_scores(s)
local i=3 local i=3
while 0<i do while 0<i do
if s[i+1]>s[i]or 0==s[i]then if (s[i]!=0 and s[i+1]*inv<=s[i]*inv) break
s[i+1],s[i]=s[i],s[i+1] s[i+1],s[i]=s[i],s[i+1]
else break end
i-=1 i-=1
end end
if(invscr_ordering)inv_scores(s)
mode-=1 mode-=1
for n=1,3 do for n=1,3 do
@ -1993,11 +1988,6 @@ function addscore(mode,score)
return i+1 return i+1
end end
function inv_scores(s)
for i=1,#s do
s[i]*=-1
end
end
-->8 -->8
--animations --animations