GodPL

GodPL Screenshot

The presumptuously named GodPL (Gamer or Deity? Programming Language) is a project I created for CS 152: Introduction to Programming Languages in Spring 2009.

The goal of the assignment was to design and implement an interesting domain-specific language.

The domain I came up with was a virtual world with simple, simulated inhabitants who could eat, move around, sexually reproduce, and die. It was inspired largely by the classic alife game, Creatures.

The language, GodPL, is a C-style language that is used to program the general behavior of a creature (called a Briyya) in the game.  It has some syntactic constructs specific to event handling and time-based events.

I defined the grammar for GodPL using ANTLR. ANTLR was used to generate a lexer and parser in C#. I then used these to write a compiler that generates C# code from GodPL, and then uses Microsoft's CSharpCodeProvider library to compile the C# to an in-memory assembly.

I integrated this with the main GodPL runtime, which I wrote in C#, using Microsoft's XNA framework for the game loop and graphics.

All of my code, as well as compiled executables and sprites, are available under the MIT License at Google Code.

There are two versions of GodPL:

  • The cs152submission tag is the version that I submitted for the course. In this one, the GodPL compiler works, but the actual simulation is somewhat buggy and not feature-complete. Several sample GodPL scripts are included. This version is interesting if you're curious about the mechanics of parsing and compiling the language.
  • The trunk has some runtime changes that break the compiler. However, this version is fun because it has a fairly extensive built-in behavior for the creatures, allows you to graphically monitor their vital signs and "genes", and has a more feature-complete simulation. [Download the installer and source]

Since this project was done over a couple of stressful weeks and several sleepless nights, obviously neither the source code nor the actual software is well-polished. However, I hope someone might find it edifying, useful, or at least entertaining.

http://godpl.googlecode.com