Tuesday, January 6, 2015

Conspire: A Programming Environment for NOWHERE

It's time for another NOWHERE tech write-up. I've been tweeting about my work on Twitter up to the point where I was nudged to write a longer blog post about what the hell I'm actually doing, so this is an attempt at doing just this. A chronological description of my trials and tribulations and where I finally ended up.

The importance of tooling can not be overstated. There are no tools out there for the kind of deeply procedural game we're working on, and good tooling comprises 90% of what makes the game, as nearly all of our content is procedural in one way or another, and not handmade. If there's currently a lack of procedural content out there, it's precisely because of the lack of tooling.

So I set out to construct an IDE in which assembling procedures in a maintainable way became easier. Inspired by UE4's Blueprints, I began with graph based editing as a guide, as graphs make it relatively easy to describe procedural flow. As a warm-up, I wrote two tiny C libraries: a theming library based on Blender's UI style, and a low level semi-immediate UI library that covers the task of layouting and processing widget trees.

The IDE, dubbed Noodles, was written on top of the fabled 500k big LuaJIT. The result looked like this:

Demonstrating compaction of node selections into subnodes, ad absurdum ;-)
A back-end compiler would translate these graph nodes back to Lua code to keep execution reasonably efficient, and I added support for GLSL code generation, something I've been planning to do from the beginning. I found that the ability to cover different targets (dynamic programming, static CPU, GPU pipelines) with a single interface paradigm became somewhat of a priority.

A simple GLSL shader in nodes, with output visible in the background.
The workflow was pretty neat for high level processing, but working with the mouse wasn't fast enough to construct low level code from scratch - refactoring was way easier though.

Noodles, shortly before I simplified the concept. Live-editing the OpenGL code for a cube rotating in the background.
I still didn't have much of an idea what the semantics of programming with nodes were going to be. I felt that the system should be able to analyze and modify itself, but a few design issues cropped up. The existing data model was already three times more complex than it needed to be. The file format was kept in text form to make diffing possible, the clipboard also dealt with nodes in text form, but the structure was too bloated to make manual editing feasible. The fundament was too big, and it had to become lighter before I felt ready to work on more advanced features.

At this point, I didn't know much about building languages and compilers. I researched what kind of existing programming languages were structurally compatible with noodles, and data flow programming in general. They should be completely data flow oriented, therefore of a functional nature. The AST must be simple enough to make runtime analysis and generation of code possible. The system must work without a graphical representation, and be ubiquitous enough to retarget it for many different domain specific graphs.

It turned out the answer had been there all along. Since 1958, to be exact.

Or 1984, if we start with SICP. Apparently everyone but me has been in CS courses, and knows this book and the fabled eval-apply duality. I never got in contact with Lisp or Scheme early on, something that I would consider my biggest mistake in my professional career. There are two XKCD comics that are relevant to my discovery here:

Did you know the first application of Lisp was AI programming? A language that consists almost exclusively out of procedures instead of data structures. I had the intuitive feeling that I had found exactly the right level of abstraction for the kind of problems we are and will be dealing with in our game.

My first step was changing the computational model to a simple tree-based processing of nodes. Here's the flow graph for a fold/reduce function:

Disassemble a list, route out processing to another function, then reassemble the list
I figured out a way to do first-order functions in a graph, and did a little demonstrative graphic about it.
Click for a bigger picture
While these representations are informative to look at, they're neither particulary dense nor easy to construct, even with an auto-complete context box at your disposal. You're also required to manually layout the tree as you build it; while relaxing, this necessity is not particularly productive.

It became clear that the graph could be compacted where relationships were trivial (that is: tree-like), in the way Scheme Bricks does it:

Not beautiful, but an interesting way to compact the tree
And then it hit me: what if the editor was built from the grounds up with Lispy principles: the simplest graphically based visualization possible, extensible from within the editor, so that the editor would factually become an editor-editor, an idea I've been pursuing in library projects like Datenwerk and Soil. Work on Noodles ended and Noodles was salvaged for parts to put into the next editor, named Conspire.

A very early screenshot. Atoms are rendered as widgets, lists are turned into layout containers with varying orientation. 
At its heart, Conspire is a minimal single-document editor for a simplified S-expression tree that only knows four immutable data types: lists (implemented as Lua tables), symbols (mapped to Lua strings) , strings (a Lua string with a prefix to distinguish it from symbols) and numbers (mapped to the native Lua datatype).

By default, Conspire maps editing to a typical text editing workflow with an undo/redo stack and all the familiar shortcuts, but the data only exists as text when saved to disk. The model is an AST tree; the view is one of a text editor.

Rainbow parentheses make editing and reading nested structures easier.
Conspire can be extended to recognize certain expressions in the same way (define-syntax) works in Scheme, and style these expressions to display different controls or data:

A numerical expression is rendered as a dragable slider that alters the wrapped number.
In the example above, the expression (ui-slider (:step 100 :range (0 1000) <value>) is rendered as a slider widget that, when dragged with the mouse, alters the <value> slot in the AST tree the view represents. The operations are committed to the undo buffer the same way any other editing operation would.

Using this principle, the editor can be gradually expanded with more editing features. One of the first things that I added was the ability to nest editors within each other. The editor's root document then acts as the first and fundamental view, bootstrapping all other contexts into place:

The root document with unstyled markup. csp-edit declares a new nested editor.
Hitting the F2 key, which toggles styling, we immediately get the interpreted version of the markup document above. The referenced documents are loaded into the sub-editors, with their own undo stack:

Tab and Shift+Tab switch between documents.
New views and controllers such as a Noodles-like graph editor could be implemented as additional AST transformers, allowing the user to shape the editor into whatever it needs to be for the tasks at hand, which in our case will be game programming.

The idea here is that language and editor become a harmoniously inter-operating unit. I'm comparing Conspire to a headless web browser where HTML, CSS, Javascript have all been replaced with their S-Expression-based equivalents, so all syntax trees are compatible to each other.

I've recently integrated the Terra low-level extensions for Lua and am now working on a way to seamlessly mix interpreted code with LLVM compiled instructions so the graphics pipeline can completely run through Conspire, be scripted even while it is running and yet keep a C-like performance level. Without the wonders of Scheme, all these ideas would have been unthinkable for the timeframe we're covering.

Oh, and there's of course one more advantage of writing your editor from scratch: it runs in a virtual reality environment out of the box.

Conspire running on a virtual hemispheric screen on the Oculus Rift DK2

Sunday, November 23, 2014

NOWHERE Progress Report November 2014

Leonard wrote in the Nowherian forum about our current progress with NOWHERE:

Right now is, hands down, the worst part of development. There are no fancy graphics to show off, no intricate gameplay, no surprising AI, no badass music, just unglamorous system design that interests no one so we can get all the aforementioned stuff in a manageable form that doesn't keep becoming a sluggish and unserviceable mess. 

Sunday, July 20, 2014

NOWHERE Progress Report: It's Going Great & Terrible At The Same Time

This post is partly an explanation of what's currently going on, partly an attempt to summarize the situation for ourselves.

First, the bad news.

With the final release of NOWHERE scheduled for the end of 2015, we're currently about 30% into development, and tech wise, it's going great. As you know our goal is to be 99% asset free, that is: all assets are generated on the players computer, for the players world, and the player will also have a chance to guide this process in the game. I've finished prototyping and embedding the meshing & landscaping tech, wrote a new procedural audio engine, and got the procedural model generator to productive speeds, on which I'll write more at a later date.

We solved some tough design issues concerning Nowherian world structure, body physique and society building, although it still all exists only in thoughts and paper, and none of that is implemented yet; Among improving our procedural authoring tools, I'm currently in the process of laying the foundation for world persistence, which is a demanding challenge. You can track my progress online at our open source repositories. I can't wait to finally work more on the actual content.

I'm sorry, I messed up, that were the good news! So, now the bad news:

We have not only been greenlit on Steam (so could theoretically release NOWHERE as Early Access game any day), but have also been accepted to talk about NOWHERE at the GDC Europe Innovative Games Showcase in August (out of what I imagine to be hundreds of applicants).

Wait, that's actually good news again. Here's the bad news. For real now.

In light of the rising complaints about Early Access games being released too early, we wanted the next alpha release to make a good impression, and so we overran our deadlines numerous times to get to a point where the game would be presentable enough for an Early Access crowd. (And we do need that crowd. The founding campaign on our own website isn't nearly attracting as many supporters as we need to cover funding for the complete development time.)

The result is that we're broke, phenomenally so. The Humble Store revenues for this month wouldn't cover our expenses sufficiently; Sylvia's dad borrowed us €1k to cover for this month but the situation is repeating. This month we're only getting $250 in revenues, but we need about $2k to cover rent, utility, food, etc.

The original planning was that a Steam release this month would give us sufficient revenues in writing (Both Humble and Steam pay out revenue with one month delay, e.g. this month we've made about $360, which are only due for payout for the end of August), so we could borrow a little more knowing that we'd be able to pay it back soon enough, and that the risk would be minimal. Alas, I can't seem to find an end for this alpha just yet, at least not one that would attract enough new interest. We gambled too hard.

I admit, we're really bad at advertising for ourselves. Talk is cheap and people want to see results, which is why I dug deep into what I love to do (writing sweet sweet game tech), and avoided doing anything that would not further development directly, such as video promotion, more interviews, and so on. This was probably not a good strategy. Now we need to find a way to fix this.

I would like to repeat that we are not ever going to give up. We're agile enough to deal with setbacks, and we own 100% of our project. This game is going to get made, whatever it takes. This is the work of a lifetime, and there is no other project we'd rather work on.

If you would like to help us out financially, and you feel you can afford to spare a small contribution on a monthly basis, please have a look at our Patreon page. Patreon contributions reach us sooner than any other revenue source.

Our fundraiser is of course also still running.

We would also again thank all our founders and supporters for your trust and contributions, you're making this project possible, and you deserve to see an excellent outcome.

Update: my amazing mom read our blog article and, since my birthday is coming up,  spontaneously decided to send us a little "birthday present" (and offered emergency loans in case this happens again), so August is saved. You all have moved heaven and earth in the past days to get us back on track too, and it worked! September appears almost covered now as well. You all are incredible and we are lucky to have such strong support! I'm back on working on the next release, and we'll be able to do one or two more alphas for founders before the Steam Early Access release. We're aiming for early August. Let's hope the trip goes a bit smoother from here on.

Thursday, May 8, 2014

Voxel Mesh Hybrids: A Walkthrough

Six more weeks have passed since I first posted about Adaptive Volumetric Meshes, which have since turned into Voxel Mesh Hybrids after some refinements for the sake of simplicity and ease of use. It's the driving tech behind the procedural and player-authored meshing that our game in production, NOWHERE (alpha available for download), requires.

After the recent refinements, it's time for another short write-up, as the work has reached a stable state and is nearly ripe for release as part of the next Alpha later this month. Beware: from here on it gets technical.

Friday, April 4, 2014

NOWHERE - News From The Business End

Aside from all the hardcore video game making going on, a bunch of super exciting business related events happened during the last few weeks as well. Enough reason to post a summary. Hold on to your seats.

March 4th: Thanks to everyone involved (which most likely includes you), NOWHERE has been greenlit on Steam. That means our greatest hurdle to a Steam release has been overcome. All existing and future buyers of the game will be able to redeem their Steam keys after launch. NOWHERE is scheduled to launch April 15th 2014 (Update: Steam launch and new alpha delayed, new alpha scheduled for June 10th!) in the Early Access category, along with a new alpha build and an accompanying trailer. Until then, you can follow new updates on NOWHERE’s Steam Greenlight page. A huge thank you to everyone who voted for us and supported us, you are amazing and the reason we got this far.

March 17th: All founders registered for access to the Founders Lounge at the Nowherian forum can now download all previously released alphas from its Release Archive, thanks to the tireless work of forum administrator Frame. If you are a founder, you are eligible for the Founders Lounge! To add founder status to your forum account, just send us an email to support-at-duangle-dot-com and mention your forum username and purchase email address. If you bought the game via Humble Store please send us a screenshot of the purchase or forward the purchase confirmation mail. I'll process every request as quickly as possible. Thank you for your patience!

March 23th: A few founders asked if it were possible to support the development of NOWHERE on a monthly basis, so we created a Patreon site. You can also pledge smaller amounts monthly to get a copy of Nowhere. Patrons pledging at least $21 will be listed in the Patreon section in the game's credits (ranked by contribution).

  March 24th: Nowhere has been launched on the official Humble Store. Please note that due to technical reasons these sales go into another bucket; the full list of reward tiers can only be purchased on our site.

  March 30th: 1.000 founders (currently 1.042) have bought and supported NOWHERE. THAT IS SERIOUSLY TOTALLY NUTS YOU GUYS.

March 31th: We visited Rezzed this weekend, listened to great dev talks and met a bunch of great people. Although videogamesing is awesome, It’s good to leave the cave and do something different from time to time. Birmingham was lovely. What in the world beats vintage cheddar? Nothing. Not even our game.

April 1st: We’re thrilled to report that Duangle got acquired by Mountain Dew for a round $2 billion sum and is renamed to Dewangle. All Nowherian bodies will be branded with appropriate new corporate identity. An exciting synergy only for people who have no idea what’s been going on lately!

April 2nd: Duncan Harris, curator and creator of the lovely website Dead End Thrills published a long interview with Leonard and me in his Rock Paper Shotgun column. Check it out!

  April 11th, 2014: The distant future. Nowhere will be playable at PAX, at the “Joyful Bewilderment” installation organized by BigSushi.fm starting April 11th between 8 p.m. and 2 a.m. in Boston, MA, USA. We’re not sure yet, but either Alpha 75 or Alpha 91 will be shown.

Monday, March 24, 2014

New Tech Unlocked: Adaptive Volumetric Meshes

This week I reached a major milestone in my implementation of the new general meshing tech for our game in production, NOWHERE (alpha available for download), which is going to replace the previous implementation we used for sculpting and will do a better job at covering the different procedural modelling approaches the game requires. To commemorate the occasion, I did a little write-up. Beware: from here on it gets quite technical. I interspersed the article with a few screenshots from the work on the prototype. These are not screenshots of the game.

Wednesday, January 22, 2014

Vote for NOWHERE on Steam Greenlight!

Although Valve has announced recently that they would rather switch Greenlight for something else, we still haven't really done something with it, although we paid the $90 admission fee a long time ago. So we figured, what the heck, let's try it. If you have nothing better to do right now, why not head over to Greenlight to give us a big smackin' YES? It will be totally worth it your time, and we may actually end up on Steam, which greatly helps our ever diminishing funding treasury.