Gambit: Software Tools for Game Theory | ||
---|---|---|
<<< Previous | The Gambit Command Language | Next >>> |
The design motifs for GCL come from two principal families of programming languages. The first is traditional imperative programming languages such as Pascal, C, and Modula-3. In particular, the GCL's concept of types draws heavily from these languages, although the number of predefined types in GCL is much larger due to the specialized nature of the language. The second is more specialized programming languages such as Mathematica, from which the GCL's grammar is partially drawn. Users with experience using any of these languages should find the GCL easy to learn; however, no programming experience is necessary to begin using the language effectively.
The GCL is a language designed primarily for building, solving and doing econometric analysis of non-cooperative games. Because the GCL is a specialized language, it has several features that are designed to make computing as easy and flexible as possible in this kind of environment. Some of the main features of the GCL are:
Specialized built-in data types with implicit typing: The GCL has a number of specialized built-in data types to represent various parts of games. For example for extensive form games, there are built in data types to represent players, strategies, nodes in an extensive form game tree, information sets, actions, outcomes, behavior strategy profiles, and an entire extensive form game. These data types are used internally by the GCL to organize computation, and keep track of important features of the objects that these data types represent.
Despite the large number of specialized data types, the GCL uses {\it implicit typing}. Implicit typing means that you never have to explicitly declare what the data type of a variable is before you use it. Variables can thus be easily created in an interactive mode to refer to any object that is a valid data type, and to save intermediate steps of computations on these data structures.
Everything is a function: Almost every statement in the GCL is built up from function calls. Briefly, a function in the GCL is a procedure that takes objects of specified data types, and uses them to construct and return an object of a (possibly different) specified data type. The GCL provides a set of Built-In Functions (BIFs), which are documented in the function reference section of this manual.
The GCL provides functions that construct simple objects of any given data type, and other functions that operate on objects of given data types to modify them or create a new object that is guaranteed to be a valid object of the given data type. A GCL program typically consists of using output from one function as input to a second, whose output is then used as input to the next, and so on. In this way, very complicated objects, such as extensive form games, can be built, all the while guaranteeing their internal consistency. In this fashion, one can construct any valid extensive form game, and (barring bugs) it is impossible in the GCL to construct an invalid extensive form game.
In addition to the built-in functions, the GCL also allows you to construct your own functions, which have exactly the same behavior as any built-in function (listablity, recursion, optional arguments, and accessible via online help)
Listability: Many objects of interest in game theory are {\it sets} (the set of players, of information sets for a player, of actions for an information set, etc.) All objects in the GCL (including lists) can be put in lists. Further, when a GCL function (with a few exceptions noted in the Function reference section) is called with a list for one of its arguments, the function is run ``listably''. This means that the function is executed for each element of the list and generates a list (or nested list) of the corresponding dimension as output. This makes it quite easy to generate objects of game theoretic interest. It also makes it easy to perform certain repetitive operations usually performed by flow control statements.
<<< Previous | Home | Next >>> |
The Gambit Command Language | Up | Data types |