Foldit calls user programs "recipes". You find them in the cookbook. Computer programs are like detailed recipes. Most poeple know you add liquids to solids so you don't get lumps and that you add the liquids slowly and stir them in. Some people wouldn't know that so the recipe would have to give the steps and ingredients in order with appropriate quantities. Well, computers are like beginner cooks. They need to have every step spelled out in full detail and with the right syntax.
One can start writing LUA scripts using the ingredients known as the built in FoldIt functions. Here's a link to the FoldIt functions on the FoldIt Wiki. Some computer languages are case sensitive and some aren't. LUA is case sensitive, that is "X" and "x" don't reference the same thing. Here's a simple script:
print('shake and wiggle')
do_shake(2)
do_global_wiggle_all(2)
print('done shaking and wiggling')
That can be done manually. Scripts get much more complex.
In addition to the built in functions one can define one's own functions and use them just like the built in functions. For instance:
function ShakeAndWiggle(x)
print('shake and wiggle for ', x, ' iterations.')
do_shake(x)
do_global_wiggle_all(x)
print('done shaking and wiggling.')
end
ShakeAndWiggle(2)
ShakeAndWiggle(4)
When I defined the function ShakeAndWiggle I told LUA that I would pass it a parameter. Some languages require you to say what type of parameter is to be passed. Sometimes one wants an integer, sometimes a real, and sometimes something else. LUA doesn't require you to specify the type but if you pass the wrong time you're going to have problems when the parameter is used. The function do_shake and do_global_wiggle_all require integers so if you give it a string the program will blow up.
As it turns out the parameter "x" in the prior example is a special case of a variable. Variables let one use names of things rather than their values. In LUA you use an equal sign to assign a value to a variable. Here are some examples:
iterations=4
mytext='Shake and Wiggle'
delta=.01
Trying writing some scripts using some of the simple built in functions. Remember to keep the capititalization you see in the documentation and include the right underscores in the right places.
Next time I'll go into a bit more detail about variables.
A journal of a FoldIt player's thoughts while learning to play the game and it's application to improving our lives.
Since this is a journal you may find starting from earlier articles helpful. I have covered a bit about the science, the FoldIT user interface, GUI recipes, and Script recipes. If you give me hints where I could be helpful I will focus in that general direction to my discretion. Currently I am going though the basic concepts of LUA script recipes. Once I get past intoductory LUA scripting I can start exploring the science of folding proteins by using LUA scripts.

No comments:
Post a Comment