a Swarm Web Interface for Experimental Economics
|
A simple Prisoner's DilemmaThe first example of the SWIEE project is an implementation of a Prisoner's Dilemma game. Before starting you can read about it in a lot of Internet sites, or you can try to loose against a Tit for Tat player with this applet.
There are some basic add-ons to the standard Swarm framework (to learn about it check resources on the Swarm Development Group site: swarm.org), here they are presented. You need to insert in a standard Swarm model a server managing the RMI connection. This class is called RemoteServer: import java.rmi.Naming; It is activated by ModelSwarm and it activates RemoteGt1 that is the Stub and Skeleton Interface and Implementation. The RemoteGt1 Interface declares methods available through RMI link, for example: import java.rmi.*; } This interface is implemented by RemoteGt1Impl.java: import java.rmi.*; .... The players' applet (Gt1Client.java) has to call the server, get the service and assign to it a reference like a normal object (called server): try { The final important piece of code is Timer.java a not-standard but very simple class that manages the synchronization between simulation and players' steps. Experimenter starts the simulation (with the instruction "java StartGt1"), then he can set some parameters, like the number of players, the number of cycles and the payoff matrix, via ModelSwarm probes; he can also set a file (and its path) to output data:
The payoff matrix must be symmetric for the two players, or the experimenter has to modify ModelSwarm source code. The standard matrix of this application corresponds to the one described by Tucker (1950, "A two-person dilemma", Stanford University Press):
with b>a>c>d and, in this application, a = b2(-1), b = a2(0), c = a1(-3) and d = b1(-6) Obviously the user can set different payoff values, changing also the structure of equilibria. The output data file is a simple text file, with different data separated by one white space, like this:
The first row presents headers for the different data, the first column presents the player's identifier. This file can be easily loaded in many useful applications for data managing. The data writing object is buffered so to not weight the server down: data are physically saved only when every round ends.
After the experimenter can push the Start button and players can load their html pages with the java applet, and so they can interact with the simulation. Player's applet:
With this applet, players can choose and read information about past rounds. In the Messages area they can read information on steps to follow; clicking on the "Game instructions" button appears the Instructions window where they can read a description of the game and where they can read the payoff matrix. Every access to this window is recorded an saved to the last column of the data output file; to get it, the Instructions window is a Java Dialog object and therefore players have to close it if they want to continue playing. The Game Instructions window:
When all cycles are gone, experimenter can access the ValueGraph of the players' performance:
Or can use other applications to manage output data file, for example:
See the Download section to download the software of this experiment and to read installation instructions. |