{"id":424,"date":"2014-02-18T18:17:29","date_gmt":"2014-02-18T10:17:29","guid":{"rendered":"http:\/\/www.gridsagegames.com\/blog\/?p=424"},"modified":"2014-06-20T15:11:17","modified_gmt":"2014-06-20T07:11:17","slug":"data-driven-development","status":"publish","type":"post","link":"https:\/\/www.gridsagegames.com\/blog\/2014\/02\/data-driven-development\/","title":{"rendered":"Data-driven Development"},"content":{"rendered":"<p>As we transition from internal developments to content creation, let us first present an overview of how most of that content is organized.<\/p>\n<p>Cogmind is an example of the &#8220;open data&#8221; model, wherein as many content-specific parts of the game are exposed in public files anyone can open up and read\/edit with a text editor. Data-driven design gives access to the parameters of game objects and more as a way to both speed up development and greatly simplify modding.<\/p>\n<p>Like the 7DRL prototype from 2012, the game comes with two versions of the data: One is the default set, encrypted to prevent tampering during competitions (oh there will be competitions!), and the other is that same default set but available as plain text. Changes small and large can be made to the latter set, then instruct the game to use that instead of the default set--bam, you have a mod.<\/p>\n<div id=\"attachment_427\" style=\"width: 257px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gridsagegames.com\/blog\/gsg-content\/uploads\/2014\/02\/cogmind_data_files.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-427\" class=\"wp-image-427 \" title=\"Cogmind Data Files (data\/objects)\" alt=\"cogmind_data_files\" src=\"https:\/\/www.gridsagegames.com\/blog\/gsg-content\/uploads\/2014\/02\/cogmind_data_files.png\" width=\"247\" height=\"265\" \/><\/a><p id=\"caption-attachment-427\" class=\"wp-caption-text\">Current contents of the &#8220;data\/objects\/&#8221; directory--still all prototype\/testing data, but the main categories are there.<\/p><\/div>\n<p>There are other data directories, but a majority of the interesting contents that make up the &#8220;game&#8221; are currently found in the objects directory: Cells (terrain), props (terrain objects like machines), entities (robots), and items (parts) are the four basic types of objects used to subdivide the world in pretty much every game I&#8217;ve ever made. At the most basic level it&#8217;s easy to tweak the parameters of a specific weapon or change a given robot&#8217;s loadout, but the data files are far more powerful than that, allowing complete control of sound effects, particle effects, and even the animated interface (the appearance of which is mostly scripted, not hard coded).<\/p>\n<p>Aside from objects, another important candidate for externalization is mechanics. Mechanics are often based on formulas, and these formulas in turn contain static values (e.g. Damage = Strength x &#8220;2.0&#8221;). Source code that leaves these values peppered throughout is a pain to deal with, and makes tweaking for balance difficult. To streamline the iterative design process these static values are always given names instead (e.g. Damage = Strength x &#8220;DAMAGE_MULTIPLIER&#8221;), and in code I keep almost <em>all<\/em> of them in a single file. (That file is literally 17% of the project&#8217;s code, by line count&#8230;) When it comes time to release, it&#8217;s pretty trivial to move them all to external files, thereby partially exposing a lot of mechanics.<\/p>\n<p>Although theoretically any text editor will do, I use Notepad++ for multi-row editing (a huge time-saver), syntax highlighting (I maintain a highlighting scheme for Cogmind&#8217;s .xt data files), and the ability to be in more than one place in a single file at the same time (plus synchronized scrolling).<\/p>\n<p>Because xml\/json require annoying markup that gets in the way of what&#8217;s important (data) no matter how nicely you format it, Cogmind .xt files use a clean tab-delimited chart format. We like our data <em>pure<\/em>. After all, the game knows what kind of data to expect and comes with a fairly robust error checker that points out any unexpected\/incorrect data when parsing the files, so why bother with all that unnecessary syntax?<\/p>\n<div id=\"attachment_436\" style=\"width: 1959px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gridsagegames.com\/blog\/gsg-content\/uploads\/2014\/02\/cogmind_data_entities.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-436\" class=\" wp-image-436 \" title=\"Cogmind Prototype Data: Entities\" alt=\"cogmind_data_entities\" src=\"https:\/\/www.gridsagegames.com\/blog\/gsg-content\/uploads\/2014\/02\/cogmind_data_entities.png\" width=\"1949\" height=\"326\" \/><\/a><p id=\"caption-attachment-436\" class=\"wp-caption-text\">Robot data from the 7DRL prototype (click for full size). Soon enough they&#8217;ll be sharing company with a new cast of friends.<\/p><\/div>\n<div id=\"attachment_438\" style=\"width: 3033px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gridsagegames.com\/blog\/gsg-content\/uploads\/2014\/02\/cogmind_data_items.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-438\" class=\"size-full wp-image-438 \" title=\"Cogmind Prototype Data: Items\" alt=\"cogmind_data_items\" src=\"https:\/\/www.gridsagegames.com\/blog\/gsg-content\/uploads\/2014\/02\/cogmind_data_items.png\" width=\"3023\" height=\"6171\" \/><\/a><p id=\"caption-attachment-438\" class=\"wp-caption-text\">Item data from the 7DRL prototype (click for full size). Most of the prototype&#8217;s 500 items were made in a single day--I expect to spend a bit longer on them this time around ;)<\/p><\/div>\n<p>Keyword highlighting is more apparent in files like the particle scripts:<\/p>\n<div id=\"attachment_440\" style=\"width: 3244px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gridsagegames.com\/blog\/gsg-content\/uploads\/2014\/02\/cogmind_data_particles.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-440\" class=\"size-full wp-image-440 \" title=\"Cogmind Prototype Data: Particles\" alt=\"cogmind_data_particles\" src=\"https:\/\/www.gridsagegames.com\/blog\/gsg-content\/uploads\/2014\/02\/cogmind_data_particles.png\" width=\"3234\" height=\"548\" \/><\/a><p id=\"caption-attachment-440\" class=\"wp-caption-text\">A sampling of the particle effect scripts for rendering a few types of lasers. All animations, including the interface, are generated from scripts like these.<\/p><\/div>\n<h2>Technical<\/h1>\n<p>Internally the entire game is centered around data. How data is stored and represented is always the first and most important part of implementing a new feature.<\/p>\n<p>Rather than risk the headaches and code bloat caused by inheritance (I&#8217;ve been there), the more complex Cogmind data objects are just a large collection of variables that are only partially used depending on the object&#8217;s subtype. Non-weapon items, for example, still have variables for damage and combat-related values, but these are ignored by the game. This is more straightforward to work with than the generic approach that is the composition model; it also doesn&#8217;t waste much memory because these extra variables only occur in static reference data.<\/p>\n<p>All static reference data is read in at the beginning of the game and stored in &#8220;compendiums&#8221; for each type of object (from robots to sound effects). Unique instances of an object, such as dozens of robots of the same type roaming the map, need only store a reference to their static data that the game should access when it needs one of those values. Unique instances need only store dynamic data, so even ridiculously huge amounts of parameters describing a base object (or huge numbers of objects period) won&#8217;t consume exponential amounts of memory in use. This is a common method of handling data in games.<\/p>\n<p>This can be taken a step further by allowing data files to specify &#8220;minor variations&#8221; of a base object by referencing the original object and indicating what specific values to assign to what variables (usually just a handful), while the game&#8217;s data loader automates the process of creating a new compendium entry. While not implemented on a large scale for Cogmind, a majority of particle variations use templates to generate the full particle definitions, thus simplifying recoloring and minor behavioral tweaks.<\/p>\n<p>There are still plenty of aspects about data that haven&#8217;t been covered here, so feel free to ask any questions!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we transition from internal developments to content creation, let us first present an overview of how most of that content is organized. Cogmind is an example of the &#8220;open data&#8221; model, wherein as many content-specific parts of the game are exposed in public files anyone can open up and read\/edit with a text editor. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":427,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[4,53,170],"class_list":["post-424","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-design","tag-cogmind","tag-data","tag-gamedev"],"_links":{"self":[{"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/posts\/424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/comments?post=424"}],"version-history":[{"count":12,"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/posts\/424\/revisions"}],"predecessor-version":[{"id":444,"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/posts\/424\/revisions\/444"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/media\/427"}],"wp:attachment":[{"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/media?parent=424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/categories?post=424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gridsagegames.com\/blog\/wp-json\/wp\/v2\/tags?post=424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}