Dante Kappotis
December 10, 2008


This project demonstrates a C++ application (in this case a simple game prototype) that relies on Scheme to handle the calculation of certain results (for this example: object creation and running the AI for a game object). This type of Scripting is extremely useful in complex, real-time applications for several reasons. Amongst the reasons are the fact that changing and recompiling code can be very time-intensive (as well as difficult to debug) and the ability to change interpreted script on-the-fly to achieve dynamic results leads to greater flexibility.


Concepts Demonstrated

  • Data abstraction and Lists are used to manage Scheme's representation of the player, enemies, and the map.
  • Tail recursion is used to solve movement-related decisions.

External Technology

The external technology used in this project is C++, which makes use of SDL (Simple Directmedia Layer) for window control, input handling, and the graphics API. The game engine prototype is implemented in C++, and Scheme is embedded within it as a scripting/AI system in order to exploit its strengths (tail recursion and adaptability, to name a few).


The innovation of this project was incorporating Scheme into a C++ application to be used as a basic scripting language. The game engine prototype has a call and response relationship with Scheme, where C++ requests that Scheme evaluate an expression or a file of expressions and, based upon the Scheme interpreter's final results, caries the desired effect through the rest of the engine, as dictated by the Scheme environment's logic. Basically, for certain operations, C++ relinquishes control over to Scheme.

Additionally, C++ and Scheme do not share the same data structures. So the player, map, and enemy objects exist (to a certain extent) in both the C++ application space as well as the Scheme environment. However, only the aspects used by each technology is managed by it. For example, Scheme keeps track of coordinates and names for objects but not graphical texture data, since the C++ code handles all of the drawing. When decisions must be made, C++ executes Scheme statements to update the environment objects, and Scheme's responses are parsed by C++ to update the executable's data structures.

Technology Used Block Diagram

Additional Remarks

In my opinion, using Scheme (or at least MzScheme) as a game scripting language has some key disadvantages to more conventional choices (such as LUA). The first of which is the much-less-than-trivial embedding process. Of course, LUA was specifically constructed with integration with languages such as C in mind. Another disadvantage is the complex organization and parenthetical syntax. In my own experience, scripting on-the-fly should be a quick and dirty task. However, one amazing advantage of Scheme is its amazing versatility! A much more complex and well-thought-out Scheme environment could allow for seamless, fast communication with C++. Also, Scheme could be used to "write its own code" and "learn" as it experienced a player's action. The simpler and easy-to-use scripting solutions lack Scheme's particular brand of versatility.