Triverse uses a simple text format for triangle grids to allow hand editing and inspection. Almost everything within the game, from drones to projectiles to terrain, is a grid composed of cells, and players can define their own grids and store them as blueprints.
Blueprints are simple by design, allowing the text grid representation to capture all information about them. Other metadata might be useful, such as turret group definitions or a forward direction designation, but I’m hoping to generate reasonable defaults and avoid complicating the format. Players can use copy + paste to get blueprints in and out of the game, although this requires platform-specific code to access the clipboard.
Here are four grids defined as text:
/c\ /c\ /t\./e\ /e\./t\ /t\./s\o/t\ /r\ /t\o/s\./t\ /t\./s\./o\b/o\./s\./t\ \./t\./.\./o\s/o\./.\./t\./ \./t\o/.\./s\./.\o/t\./ \c/.\t/ \t/.\c/ \c/t\./t\c/ /c\ /c\ /t\c/.\c/t\ /.\m/.\ /t\o/s\o/t\ /.\m/.\ /t\b/.\./o\s/o\./.\b/t\ \l/o\s/o\./t\s/t\./o\s/o\l/ \t/o\t/ \t/.\t/ \t/o\t/ \t/.\t/ \t/.\t/ \./ \./
And the equivalent blueprints in game:
And finally, the completed physical grids in game:
Multiple grids can go in a file, with annotations added to assign names and delimit grids. Using delimiters also allows for multiple disconnected segments which are part of the same grid, allowing blueprints to define fleets.
# unit-md-12 /.\r/.\ /.\r/.\ \t/.\s/o\t/o\s/.\t/ \t/o\t/ /t\ /t\s/t\ /t\o/t\ \./c\./ \t/.\t/ # unit-md-13 /m\ /r\ /m\ /t\./s\o/s\./t\ \c/o\s/t\t/ \t/t\s/o\c/ /t\s/t\ /t\s/t\ \./t\./ \./t\./
Each character represents a type of part and the slashes determine whether the cell is a triangle pointing up or down. The format allows for variations like omitting all but one slash to determine cell orientation, but I find it helpful in visualizing the grid to include them throughout. Pipes as delimiters instead of newlines could help for representing a grid on a single line.
The game maps part types to actual part definitions using a table. This table defines character codes and attributes of parts, including energy requirements, turret behavior, and any other information related purely to gameplay logic. Other information, such as visuals and audio, are decoupled from these definitions and placed in a separate table. I imagine modding scenarios where one or both tables could be easily swapped out. However, this use of character codes imposes a convention on custom tables if a modder wants to support existing grids: if a thruster (t) is suddenly mapped to an assembler (a), the ships wouldn’t work as intended.
Creating this visual serialization format has boosted my productivity in testing and development in general. It makes defining test cases incredibly easy and allows for quick comparison of results. In general, I prefer investing in this kind of printf-style debugging where effort is spent in good logging and visualizing game state rather than sessions with a debugger. The text format is also what inspired me to pursue a turn-based design, and I’ve even considered an in-game text mode.
#triverse #grids #technical