But some words for comfort:
I created a script which does snapping and wiggling, but it turned out that it didn't make big points:
http://fold.it/portal/recipe/6235
So, sticked on using shake again (which is some kind of auto-snapping).
If I had been able to reproduce the error I would have created special code since I'm already identifying segment#, old amino and new before I try the snaps. I didn't want to modify the code until I could reprodcue segment and amino since it could cause different behavior. The fewer changes the better.
I'll try using pcall to see if foldit's lua implementation can trap the ligand when mutating last sement. My energy doesn't let me do as much as I'd like. If I can trap the error I can set a global indicating the puzzle is a ligand puzzle. If I could detect snap position I could detect locked sidechains in a similar way to identifying mutable segments. I'm pretty sure I could just go though the snap positions and see if score changed. If score doesn't change the segment's sidechain is locked. Since a recient puzzle has some unlocked sidechains on immutable segments this would be helpful knowledge in improving score.
What is pcall?
At the moment, I do it this way to identify a ligand puzzle:
http://fold.it/portal/recipe/13246
Right, by changing snap positions and watching score, you can check if the current sidechain you are working on is locked or not.
But the best would be if there were any functions which can tell us this.
See, the game already "knows" what is allowed and what not, so testing it again to transfer this information to Lua's guts is always some kind of double-doing to me.
regards,
Alex
It seems like one could call x=pcall(replace_aa, 'a') and find out if it threw an error. I haven't tried this yet. Too much to do when I get home to try everything at once.
from: http://www.lua.org/manual/5.1/manual.html#pdf-pcall
pcall (f, arg1, ยทยทยท)
Calls function f with the given arguments in protected mode. This means that any error inside f is not propagated; instead, pcall catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message.
xpcall (f, err)
This function is similar to pcall, except that you can set a new error handler.
xpcall calls function f in protected mode, using err as the error handler. Any error inside f is not propagated; instead, xpcall catches the error, calls the err function with the original error object, and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In this case, xpcall also returns all results from the call, after this first result. In case of any error, xpcall returns false plus the result from err.
Sounds helpful, but as far I've read this function is part of the Lua basic library, which is not included in Foldit at the moment.
So, again a vote for the standard Lua library.
I'll verify this evening if it works or not. Lunch is over so I've got to go back to work.
I can understand limitations that prevent me from writing to disk even though that would be very helpful but basic error trapping seems of little risk to security. I guess I could try the roundabout
x=assert(replace_aa('g') == nil, 'who knows it might work')
assert is implented. I've seen it used in tlaloc's scripts.
I don't know if it's generally true but on 367:
print(get_ss(get_segment_count()))
returns M. Wouldn't that be simple?
pcall isn't implemented.
assert didn't trap the error.
Not E for sheet, H for helix or L for loop, it's M (mixed?), really :)
You had a good intuition!
Yes, it would be good, if this would be the case for all ligand puzzles.
Makes it very simple to fetch if there is a ligand.
Maybe we should ask the developers if it is always the case.
OK, Here's the problem. I'll show three pictures. Look at the recipe output.
OK, I'll switch to the repeat loop but why would the snap count change when snapping
through the possibilities?