We ported the original Doom to SQL
In a groundbreaking project, the original 1993 game Doom was successfully ported to SQL. The game logic and renderer were executed inside a database, allowing the game loop to run at the original 35 FPS, while the renderer produced the complete 320x200 frame buffer at up to 60 Hz on a laptop. Python was solely responsible for handling timing, reading the keyboard, and displaying the bitmap returned by the SQL engine.
Multiplayer functionality was also implemented, enabling four players to participate in first-come, first-served matches. The game can be played immediately in deathmatch mode, with users queuing if all slots are taken.
The process of porting Doom to SQL began with establishing baseline rules: Python would be deliberately boring, a single script would drive input and output, and the game logic, state, and renderer would all reside within the database. The game logic runs on a fixed 35 Hz loop, while the renderer operates independently, responding to requests for new frames as quickly as possible.
Doom's .wad file format, which consists of VERTEXES connected by LINEDEFs, bounded SIDEDEFs, and SECTORs with THINGS, provided an inherently relational structure that was straightforward to translate into a database. This conversion took about 1000 lines of Python and took approximately 18 seconds to import all of Doom 1 on the author's laptop.
The core of the project involved translating Doom's game logic into SQL, resulting in around 5,900 lines of SQL code, which is significantly less than the original C source code's 9,000 lines. This SQL implementation leveraged SQL's ability to handle complex data processing more efficiently than C, allowing the database to handle entity component interactions and rendering with greater ease.
The rendering pipeline consisted of several components, including a BSP-based system that processed game tics in about 10.45 milliseconds on average, or 8% of the available budget, leaving ample headroom for additional processing.
In summary, this unique project successfully ported the original Doom game to SQL, running at the original frame rate while leveraging the power and efficiency of a database for rendering, game logic, and multiplayer functionality.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.