A computer scientist used only “pure SQL” to construct a multiplayer DOOM-like game. The resulting first-person shooter game, cobbled from a mere ~150 lines of Python code, is dubbed DOOMQL. Despite the self-imposed software architecture restrictions, Lukas Vogel, co-founder of database performance outfit CedarDB, says DOOMQL plays at “a breezy ~30 FPS.” It isn’t the most graphically splendid DOOM-inspired game, though.
Vogel’s SQL-powered DOOM dreams were precipitated by Patrick Trainer’s DuckDB-DOOM. This earlier experiment in code also sought to create a DOOM-like first-person shooter in SQL. However, Trainer's code, which runs in a single web page in a browser using WebAssembly, also uses JavaScript for rendering and inputs.
You can deep dive into Vogel’s SQL-powered DOOM via the linked blog post, and check out the code on GitHub. For a brief overview of the game architecture, though, it can be surmised at the high-level by the following quartet of bullet-points:
- State lives in tables (map, players, mobs, inputs, configs, sprites, …)
- Rendering is a stack of SQL views that implement raycasting and sprite projection.
- The game loop is a tiny shell script that executes a SQL file ~ 30 times per second.
- The client is ~ 150 lines of Python: It polls for input and queries the database for your 3D view.
Vogel ended up learning a lot about SQL as a way to implement game logic and state management, with a “surprisingly elegant game loop” emerging from his efforts. The performance, as previously mentioned, was a pleasing point, too, and he challenges readers to come up with a database system faster than CedarDB (co-founder’s shameless plug) to render DOOMQL.
If you want to try out DOOMQL for yourself, head on over to the GitHub repository. Once you grab all the files, you can run it locally using Docker and Python. Since you have the code, under the flexible MIT License, you’ll be able to see and play around with it all yourself. Vogel hints that he will be looking at a handful of improvements in the not-too-distant future. Specifically, he mentions things like “adding power-ups, multiple weapons, cleaning up the sprite LOD system, a better client, AI opponents.”
Follow Tom's Hardware on Google News, or add us as a preferred source, to get our up-to-date news, analysis, and reviews in your feeds. Make sure to click the Follow button!