{"id":50703,"date":"2020-09-08T06:00:43","date_gmt":"2020-09-08T10:00:43","guid":{"rendered":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=50703"},"modified":"2020-09-19T20:15:25","modified_gmt":"2020-09-20T00:15:25","slug":"project-bug-hunt-1-what-are-we-doing","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=50703","title":{"rendered":"Project Bug Hunt #1: What Are We Doing?"},"content":{"rendered":"<p>As I&#8217;ve alluded to before, I&#8217;ve been working on a new programming project. Like <a href=\"?p=23380\">most<\/a> of <a href=\"?p=15742\">my<\/a> <a href=\"?p=2940\">other<\/a> <a href=\"?p=11874\">projects<\/a>, this one is tied to procedural content generation. While the <a href=\"?p=20638\">Good Robot<\/a> project turned into <a href=\"https:\/\/store.steampowered.com\/app\/358830\/Good_Robot\/\">a real video game<\/a>, most of these projects are intended to be experiments, educational projects, or proof-of-concept demos. I guess this project is all three.<\/p>\n<h3>What are we Doing?<\/h3>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/bughunt_goal.jpg' width=100% alt='I want something just like this, except completely different.' title='I want something just like this, except completely different.'\/><\/div><div class='mouseover-alt'>I want something just like this, except completely different.<\/div><\/p>\n<p>Our goal is to make a procgen shooter level. It probably won&#8217;t matter, but I&#8217;m aiming for something that would work as an<a href=\"https:\/\/www.youtube.com\/watch?v=kbyTOAlhRHk\"> immersive sim<\/a><span class='snote' title='1'>Yes, this is a confusing and awkward name for this genre. It was named back in the 90s when a lot of genre boundaries hadn&#8217;t settled in and we were still calling shooters &#8220;Doom Clones&#8221;.<\/span>, not a turbo-charged run-n-gun shooter. Games like <em>System Shock<\/em>, <em>System Shock 2<\/em>, and <em>Prey<\/em> are some of my most beloved games. I like how the space station setting allows for open-ended exploration without needing to contrive a silly wall around the world to keep the player in the playpen. I like how the isolated setting creates a quasi survival horror vibe, where you&#8217;re all alone in a haunted box full of monsters. I like how combat is slow-paced and risky, and I like having to balance my supply of ammunition, weapons, tools, and healing items.<\/p>\n<p>I also give partial credit to games like Thief, Deus Ex and Dishonored for being Immersive Sims, even if they don&#8217;t take place in my favorite settings or feature the open-endedness I&#8217;m looking for. I give partial-partial credit to the BioShocks for being watered-down examples of the formula.<\/p>\n<p>You can argue over genre boundaries all day, but you don&#8217;t need to haggle with me that game X should be included or game Y should be excluded. It&#8217;s fine. You can decide for yourself what Immersive Sim really means, but it&#8217;s not going to change my design. I&#8217;m just trying to make something I&#8217;d like, which means a procgen space station \/ space ship setting.<\/p>\n<p>I&#8217;m not going to be adding AI or monsters to fight, so this focus on &#8220;Immersive sim levels&#8221; is mostly academic. I just want to head off objections that the stuff I&#8217;m building wouldn&#8217;t work as a shooter because it&#8217;s too constrained to allow for insane run speeds and rocket-jumping.<\/p>\n<p>So anyway, back to defining our overall goals&#8230;<\/p>\n<p><!--more--><\/p>\n<p>We want to design a level layout, turn it into polygons, fill it with stuff, light it, add some sort of basic interactivity<span class='snote' title='2'>Probably moving doors and other simple moving objects.<\/span>, include some basic sounds, and let the player explore it all. I don&#8217;t expect to add real gameplay, but to keep with the spirit of the project the end product should be <b>capable<\/b> of working from a gameplay sense. The space should be coherent in the sense of having a complete route from the starting point to the ending point. It should be something that an AI could navigate. A few things should emit sounds to prove that the program is capable of it and has a way of placing correct sounds in sensible locations. The lighting should make sense, and there should be proper collision detection on everything.<\/p>\n<p>While visuals don&#8217;t matter in a tech demo, I&#8217;m going to strive to make something vaguely presentable. It certainly won&#8217;t look like something you could ship to consumers, but it should be something that could be made cool with the help of an artist that knows what they&#8217;re doing.<\/p>\n<p>Another goal is to limit complexity of the code. I&#8217;m normally inclined to do things &#8220;the right way&#8221; the first time, but for this project I&#8217;m sort of trying to find out what the Right Way <b>is<\/b>. So instead of building complex and optimized code, I&#8217;m going to focus on writing as little code as possible. The idea is that when I change my mind, I want to feel free to throw old code away and do something completely different. That&#8217;s hard to do if you&#8217;re thinking, &#8220;No! I spent two weeks on this! I can&#8217;t just throw it out!&#8221;<\/p>\n<p>An additional bonus goal is that it should be possible to change the procgen parameters without changing the code.<\/p>\n<h3>Magic Numbers<\/h3>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/bughunt_math.jpg' width=100% alt='Well shit. I knew I should&apos;ve done the reading before class.' title='Well shit. I knew I should&apos;ve done the reading before class.'\/><\/div><div class='mouseover-alt'>Well shit. I knew I should&apos;ve done the reading before class.<\/div><\/p>\n<p>See, every game runs on &#8220;magic numbers&#8221; to some degree. Maybe you&#8217;ll see the number 1.655 in the code. If the programmer is responsible and sane, then they&#8217;ll assign this number to a variable with a helpful name like &#8220;playerHeight&#8221; so you understand what the number is for and even have a chance to figure out what units this number is in<span class='snote' title='3'>It&#8217;s meters, BTW.<\/span>. If the programmer is lazy or inexperienced, then they&#8217;ll just name the variable &#8220;height&#8221; and you&#8217;ll be left wondering &#8220;Um. Height of WHAT? A font? A jump? Screen size? What scale are we dealing with? Miles? Feet? Pixels? Megapascals? Building stories? Parsecs? <a href=\"https:\/\/what-if.xkcd.com\/44\/\">Giraffes<\/a>?&#8221;<\/p>\n<p>You end up with a lot of numbers like this in a game. You need numbers for height, speed, hitpoints, weapon accuracy, monetary value, volume level, damage inflicted, sight distance, weight, friction, cooldown time, mana cost, magazine capacity, font size, stack size, particle size, effective duration, and gluten content. The thing is, these numbers control gameplay, and that usually isn&#8217;t the programmers&#8217; job. If the team decides that the AR-15 needs 15% more gluten, then the gameplay designer shouldn&#8217;t need to make a request to the programmers asking them to set aside their long and highly technical work so they can find a number somewhere in the code and change it.<\/p>\n<p>So you put all the magic numbers into some sort of settings file where the design team can fiddle with them as much as they want without dragging coders away from their jobs.<\/p>\n<p>You won&#8217;t be able to use these numbers to turn a shooter into a Minecraft clone or a 2D platformer into a visual novel, but you should be able tweak the behavior of the game. In the case of this project, that would mean fiddling around with procgen parameters to make different kinds of spaces<span class='snote' title='4'>I&#8217;ll probably use XML to store these numbers.<\/span> so we&#8217;re not trapped with a hard-coded system. When I worked on Good Robot, <a href=\"http:\/\/www.seventh-house.org\/2020\/09\/18\/astral-horizon\/\">Ross Zevenhuizen<\/a> was able to do a lot of things that had never occurred to me using the settings files. It&#8217;s a little more work, but it can really pay off if your art team is up for experimenting with things. Of course, I imagine I&#8217;ll be the only one working on the project. But still. It&#8217;s nice to be able to make quick changes without needing to re-compile whenever you want to iterate over a new idea.<\/p>\n<h3>But Why?<\/h3>\n<p>This project is the product of many inspirations. In chronological order:<\/p>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/bughunt_systemshock2.jpg' width=100% alt='All these people wore the same outfit to work today. They were evidently so embarrassed about it that they beat themselves to death with a wrench. Tragic.' title='All these people wore the same outfit to work today. They were evidently so embarrassed about it that they beat themselves to death with a wrench. Tragic.'\/><\/div><div class='mouseover-alt'>All these people wore the same outfit to work today. They were evidently so embarrassed about it that they beat themselves to death with a wrench. Tragic.<\/div><\/p>\n<p><strong>1) System Shock 2<\/strong><\/p>\n<p>Way back in 1999, I got sorta hooked on <i>System Shock 2<\/i>. I have no idea how many times I&#8217;ve played through the game, but it&#8217;s probably at least a dozen<span class='snote' title='5'>Disclosure: I never cared for the end section where you enter the fleshy tunnels to face the Many. I think I&#8217;ve only played through that four or five times. I usually get to the point just before the Many, and then declare the game over, quit to the main menu, and start a new game.<\/span>. At some point I had to stop playing because I&#8217;d memorized all of the loot and gotten stuck in the rut of an overly-optimized run. I wished there was a way to randomize all the loot and enemy positions so I could return some sense of mystery and surprise to the experience.<\/p>\n<p>Also, I noticed that the levels were actually pretty simple. Unlike the convoluted multi-level maps of the late 90s, System Shock 2 was designed to look like a reasonable human-designed space that could be depicted on a 2D map. It didn&#8217;t depend on labyrinthine tunnels, winding corridors, or stacked room design<span class='snote' title='6'>There was a <b>little<\/b> vertical movement, but it was very simple compared to contemporaries like the Unreals, the Quakes, or Half-Life<\/span>. <i>System Shock 2<\/i> was mostly a main corridor that branched off into cuboid side-rooms. Procgen systems code ought to work really well with that sort of thing.<\/p>\n<p><strong>2) The Lost Project<\/strong><\/p>\n<p>Back in 2015, I worked on <a href=\"?p=27403\">this project<\/a>:<\/p>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/generic_project2.jpg' width=100% alt='This was made using my homebrew engine in C++.' title='This was made using my homebrew engine in C++.'\/><\/div><div class='mouseover-alt'>This was made using my homebrew engine in C++.<\/div><\/p>\n<p>You can see additional screenshots of the project in <a href=\"?p=26269\">my OpenGL series<\/a>. That project served multiple purposes. It was a failure on all counts, but it was an educational kind of failure. I wish I&#8217;d written about it at the time, because I&#8217;d love to read through that process before embarking on this project.<\/p>\n<p>The main purpose was to experiment with blending modern rendering techniques with retro styling to see what it would look like. That didn&#8217;t work out for the reasons I explained in the middle of <a href=\"?p=27403\">this post<\/a>.<\/p>\n<p>The secondary purpose was to experiment with procgen level design. I was trying to make something really open-ended that could generate a 90s style deathmatch level, and the lack of structure made it impractical. The space would end up being boring, cluttered, non-sequitur rooms. I found myself gravitating towards using prefab pieces, but I felt like that went against the intent of what I was trying to do. I discovered that you need some limitations and structure or the whole problem becomes too abstract. So now I want to take those lessons and try again with a different approach.<\/p>\n<p><strong>3) Strafe<\/strong><\/p>\n<p><a href=\"?p=41285\">I played Strafe a few years ago<\/a>. <\/p>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/2017_strafe2.jpg' width=100% alt='Three years later, and I still have no desire to return to this game. Shame. I loved the art.' title='Three years later, and I still have no desire to return to this game. Shame. I loved the art.'\/><\/div><div class='mouseover-alt'>Three years later, and I still have no desire to return to this game. Shame. I loved the art.<\/div><\/p>\n<p>I liked the idea of a procgen level, but in the end a level was mostly a chain of prefab pieces. I&#8217;d walk into a room and go, &#8220;Oh yeah. This one again.&#8221; That&#8217;s not <b>bad<\/b> or anything. It&#8217;s more than other games attempt. But I still felt like there was more that could be done with the idea. Authors of 2D side-scrolling roguelikes have gotten really good at making procedural 2D gamespace, but very few people are trying for that sort of limitless variety in 3D. Yes, it&#8217;s true that 3D is many times harder than 2D, but I think it&#8217;s a reasonable idea to strive for.<\/p>\n<p><strong>4) System Shock Remake<\/strong><\/p>\n<p>I&#8217;m still following the development of the <a href=\"https:\/\/www.kickstarter.com\/projects\/1598858095\/system-shock\/posts\">System Shock remake<\/a>, and every time I see a new video or screenshot I find myself thinking how good this particular grid system would be for procgen levels. <\/p>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/bughunt_systemshockremake.jpg' width=100% alt='This is a lot more pink than was in the original, and I don&apos;t recognize this particular corridor, but it&apos;s still pretty cool.' title='This is a lot more pink than was in the original, and I don&apos;t recognize this particular corridor, but it&apos;s still pretty cool.'\/><\/div><div class='mouseover-alt'>This is a lot more pink than was in the original, and I don&apos;t recognize this particular corridor, but it&apos;s still pretty cool.<\/div><\/p>\n<p>In the original System Shock, spaces are built on a 2-meter grid. You can use any cube or wedge shape that fits in that grid. That would work really well with a system that branched off corridors into smaller corridors into rooms.<\/p>\n<p>I&#8217;m not going to actually use this grid system, but seeing the screenshots makes me want to do procgen stuff.<\/p>\n<p><strong>5) Project Hammertime<\/strong><\/p>\n<p>Earlier this year I did that <a href=\"?p=49740\">weird project where I tried to load Half-Life levels from the Hammer editor into my Unity game<\/a>. <\/p>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/basalt_path_tracing.jpg' width=100% alt='No, we&apos;re not going to be using raytracing in this project. It&apos;s cool, but this feature is not ready for realtime rendering in Unity.' title='No, we&apos;re not going to be using raytracing in this project. It&apos;s cool, but this feature is not ready for realtime rendering in Unity.'\/><\/div><div class='mouseover-alt'>No, we&apos;re not going to be using raytracing in this project. It&apos;s cool, but this feature is not ready for realtime rendering in Unity.<\/div><\/p>\n<p>That was fun and made me want to do more programmy-type stuff. And yes, it was actually called &#8220;Hammertime&#8221;, even though I never confessed that during the write-up.<\/p>\n<h3>For the Unity!<\/h3>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/bughunt_unity.jpg' width=100% alt='Evidently Steppenwolf is a huge fan of Unity?' title='Evidently Steppenwolf is a huge fan of Unity?'\/><\/div><div class='mouseover-alt'>Evidently Steppenwolf is a huge fan of Unity?<\/div><\/p>\n<p>If you&#8217;ve been following my site for the last few years, then you probably won&#8217;t be surprised to learn that I&#8217;m going to be doing this in Unity.<\/p>\n<p>Before Unity, I did all my projects by hand in C++. That&#8217;s cool, but I dropped a lot of projects because I was sick of needing to constantly build infrastructure for myself. C++ is really barebones. No built-in rendering pipeline. No support for 3D models. No sound, no physics, no collision detection, no font support, no controller support, no skeletal animation, and no support for image loading. Yes, there are free libraries for all of this stuff out there. But finding them, figuring out how they work, and getting them to inter-operate gracefully is still a monstrous task. It&#8217;s perfectly normal for me to spend far more time building infrastructure than working on the problem I&#8217;m interested in.<\/p>\n<p>At the other end of the spectrum, Unreal Engine is way too heavy for small experimental projects like this. Also, I&#8217;ve never seen anyone doing serious live procgen content using the engine. Unreal seems to be built around the idea of loading premade assets. Okay, there&#8217;s <a href=\"https:\/\/www.youtube.com\/watch?v=mI7eYXMJ5eI\">this one video<\/a> that&#8217;s one of those insufferable live training sessions. The end product was needlessly convoluted and impractical and in the end it was basically a randomizer for a <a href=\"https:\/\/www.youtube.com\/watch?v=qR_sQEs8jTk\">Doom 2016 snapmap<\/a> setup. That&#8217;s&#8230; completely inadequate. If Unreal has any real tools or even basic allowances for making your own assets at runtime, I&#8217;ve never seen it documented or demonstrated.<\/p>\n<p>I was hoping <a href=\"?p=47821\">Jai<\/a> would be out by now<span class='snote' title='7'>It was supposed to be available at the end of 2019.<\/span>, and I&#8217;ve been sitting on this project for months in the hope that Jai would come out. But it&#8217;s late in 2020 now and we still don&#8217;t have a revised date for any kind of public release. I&#8217;d love to try Jai, but I think I need to move on and come back when Jai is available and the community has worked out a rough set of standard practices, documentation, and maybe some quasi-standard libraries. Waiting until the first round of bug fixes would probably be smart too.<\/p>\n<p>So that&#8217;s the plan. We start next week.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I&#8217;ve alluded to before, I&#8217;ve been working on a new programming project. Like most of my other projects, this one is tied to procedural content generation. While the Good Robot project turned into a real video game, most of these projects are intended to be experiments, educational projects, or proof-of-concept demos. I guess this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-50703","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/50703","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=50703"}],"version-history":[{"count":12,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/50703\/revisions"}],"predecessor-version":[{"id":50772,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/50703\/revisions\/50772"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=50703"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=50703"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=50703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}