In economic experiments the strategy method is used quite often. The participant has to make decisions for all possible situations. For example worker in a gift exchange has to decide for all possible wages that can be received how much effort will be exerted (e.g. Sandra Maximiano, Randolph Sloof and Joep Sonnemans (2007) Gift exchange in a multi-worker firm. Economic Journal 117, 1025-1050 Link to article). This strategy is executed after the truster has made his choice.
But there are also another kind of strategy experiments, where each subject has to formulate an algorithm, for example predicting a future market price based on realized prices, or how to play a minority game. After all strategies are handed in, simulations are run and the participants get paid according to performance in these simulations. Typically this is repeated several times (over a few weeks).
The problem by letting participants handing in strategies on paper (and put in the computer buy the experimenter) is that you never know whether the strategy is really what the participant wanted (for examples see Joep Sonnemans, Cars Hommes, Jan Tuinstra and Henk van de Velden (2004) The Instability of a Heterogeneous Cobweb Economy:a Strategy Experiment on Expectation Formation Jounal of Economic Behavior and Organization 54, 453-481 Link to article). It would be nice if the participants could test their own strategy in simulations. This can be done in php! Php has the infamous function eval()
which evaluates a string as a line of program code. This function is infamous because it is used by hackers to hack unsafe websites. When you run a strategy experiment online, you have to be careful and allow only specific words in the strategy.
It would be very hard for subjects to formulate an algorithm from scratch. Therefore we we used a javascript text editor and all the strategies had to have the form if (condition) {return number;}
where the condition could use the outcomes of previous (5) periods and the number returned is the probability that the strategy changed colors. As many if-statements could be used as the participant liked. As you see the in the screenshot a small explanation was shown when you moved the mouse over a button.
We didn't build the editor from scratch. We used a javascript text editor we found on internet and we added many buttons and behavior. When the strategy is submitted to run a simulation, a first check was made, for example whether there are as many {'s than }'s and as many ('s as )'s.
The subject could run simulations against other strategies (from the previous period), and we kept track of all behavior (login, logout, all strategies they tried, the simulations they run, etc.).
If in your experiment participants can login from elsewhere (like in the minority experiment) you have to test carefully the site on different computers (and tablets) and in different browsers.
You can play the experiment yourself here: online version of the minority experiment and more documentation you can find in the article, published in Games and Economic Behavior. The software is also available on request.