Icon representing a recipe

Recipe: Rosetta energy 1.1

created by LociOiling

Profile


Name
Rosetta energy 1.1
ID
108243
Shared with
Public
Parent
Rosetta energy
Children
None
Created on
March 29, 2023 at 17:07 PM UTC
Updated on
April 02, 2023 at 20:46 PM UTC
Description

Demonstrate converting Foldit energy to Rosetta energy. Version 1.1 calculates the Rosetta energy awarded by conditions. V 1.1 also displays totals at the end, in addition to much more detailed output in scriptlog.

See https://foldit.fandom.com/wiki/Free_energy

Best for


Code


print ( "Rosetta energy 1.1") print ( "" ) function r3(x) return x - x % 0.001 end print ( "phase 1 - convert Foldit score to Rosetta energy units" ) print ( "" ) filter.EnableAll () -- enable all conditions (filters) local sFoldit = current.GetEnergyScore () print ( "Foldit energy score = ".. r3 ( sFoldit ) ) local sRosecon = 10 * ( 800 - sFoldit ) print ( "converted Rosetta score = " .. r3 ( sRosecon ) ) print ( "Rosetta score calculated using the formula 10 * ( 800 - Foldit energy score )" ) print ( "" ) print ( "phase 2 - compare Rosetta score from scoreboard.GetScore") print ( "" ) print ( "this section compares the phase 1 Rosetta score to the scoreboard.GetScore value") print ( "scoreboard.GetScore doesn't seem be be working as of March, 2023") print ( "" ) local sRosetta = scoreboard.GetScore () print ( "Rosetta energy score = ".. r3 ( sRosetta ) .. " , from scoreboard.GetScore" ) local sCheck = sRosetta - sRosecon == 0 print ( "check: phase 2 Rosetta score - phase 1 Rosetta score = 0 " ) print ( r3 ( sRosetta ) .. " - " .. r3 ( sRosecon ) .. " = 0 (" .. tostring ( sCheck ) .. ")" ) local filtz = filter.GetNames () local froset = 0 -- total Rosetta energy from conditions if #filtz > 0 then print ( "" ) print ( "phase 3 - Rosetta score for conditions (aka filters)" ) print ( "" ) print ( #filtz .. " conditions found for this puzzle") print ( "" ) filter.EnableAll () local sEnabled = 10 * ( 800 - current.GetEnergyScore () ) print ( "overall Rosetta score with all conditions enabled = " .. r3 ( sEnabled ) ) local sEntotal = 10 * -filter.GetBonusTotal () print ( "Rosetta bonus with all conditions enabled = " .. r3 ( sEntotal ) ) local sFolditEn = filter.GetBonusTotal () print ( "Foldit bonus with all conditions enabled = " .. r3 ( sFolditEn ) ) print ( "" ) filter.DisableAll () local sDisabled = 10 * ( 800 - current.GetEnergyScore () ) print ( "overall Rosetta score with all conditions disabled = " .. r3 ( sDisabled ) ) local sDistotal = 10 * filter.GetBonusTotal () print ( "Rosetta bonus with all conditions disabled = " .. r3 ( sDistotal ) ) local sFolditDis = filter.GetBonusTotal () print ( "Foldit bonus with all conditions disabled = " .. r3 ( sFolditDis ) ) print ( "" ) local fbont = 0 for ii = 1, #filtz do if filter.HasBonus ( filtz [ ii ] ) then filter.Enable ( filtz [ ii ] ) local fbon = filter.GetBonus ( filtz [ ii ] ) fbont = fbont + fbon local frose = 10 * -fbon froset = froset + frose print ( "condition \"" .. filtz [ ii ] .. "\" bonus, Foldit = " .. r3 ( fbon ) .. ", Rosetta = " .. r3 ( frose ) ) filter.Disable ( filtz [ ii ] ) else print ( "condition \"" .. filtz [ ii ] .. "\" does not award a bonus" ) end end print ( "bonus total, Foldit = " .. r3 ( fbont ) .. ", Rosetta = " .. r3 ( froset ) ) filter.EnableAll () print ( "Rosetta score with disabled conditions " .. r3 ( sDisabled ) .. " + total bonus " .. r3 ( froset ) .. " = Rosetta score with enabled conditions " .. r3 ( sEnabled ) ) print ( "check: Rosetta score with disabled conditions + total bonus = Rosetta score with enabled conditions" ) local sCheck = sDisabled + froset == sEnabled print ( r3 ( sDisabled ) .. " + ( " .. r3 ( froset ) .. " ) = " .. r3 ( sEnabled ) .. " (" .. tostring ( sCheck ) .. ")" ) end local opt = dialog.CreateDialog ( "Rosetta energy 1.1" ) opt.lbl1 = dialog.AddLabel ( "calculated Rosetta energy" ) opt.lbl2 = dialog.AddLabel ( "Rosetta energy calculated using the formula:" ) opt.lbl3 = dialog.AddLabel ( "REU = 10 * ( 800 - Foldit energy score )" ) opt.rosetta = dialog.AddTextbox ( "total: ", r3 ( sRosecon ) ) if #filtz > 0 then opt.froset = dialog.AddTextbox ( "from conditions: ", r3 ( froset ) ) end opt.ok = dialog.AddButton( "OK", 1) local re = dialog.Show ( opt )

Comments


Artoria2e5 Lv 1

Got scoreboard -1866.807 for Foldit score 26668.06. That seems to be working as intended if you swap the expression into Foldit = 10 * (800 - REU). In that case, foldit-to-rosetta conversion is REU = 800 - Foldit / 10.