General Compute Coprocessor

From Esolang
Jump to navigation Jump to search

General Compute Coprocessor (GCC) is one of the languages used in the ICFP contest 2014.

GCC is a virtual machine intended for running a lisp-like untyped functional language compiled to it. There are built-in instructions to create an environment with values (as a let statement requires), call closures with an environment of values indexed by small integers, to read variables from the current environment or one or more levels of environment below. There are also instructions to allocate cons pairs and read their fields, and arithmetic instructions handling 32-bit integers. Data (cons cells, environments, and closures) are automatically garbage-collected. From the description it appears that closures hold a reference the full environment of all their containing functions, including all variables in those functions, although in theory the garbage collector could analyze the code of the closures to determine which of those variables may still be used. There's also an extension for mutable variables in environments.

In the story of the contest, the LamCo company used this language to control the AI of Pacman in their arcade computer running a Pacman-like game when a single player wants to play a two-Pacman game. The operating system calls the main function in the GCC instance when the game is initialized, gets an update function, then calls this on each tick, it calls this update function with the game state and an accumulated AI state to determine what the AI Pacman should do.

External links