For a game as complex and as huge as The Witcher 3, it's hard to imagine one of its core gameplay elements—one that ties the entire game together—didn't actually exist until mere months before its release. And yet, according to senior gameplay designer Matthew Steinke speaking at GDC Europe, that's exactly what happened with The Witcher 3's economy, crafting, and inventory systems. These three core elements of the game were "fragmented and incomplete" to the point that "there was no time left in the project to accomplish everything by the deadline."

But as is so often the case, a complex task and a rapidly looming deadline can lead to some great innovations. For Steinke and The Witcher 3, that meant coming up with an entirely new way to create and maintain an in-game economy; one that was reactive to the player and the world around it. Steinke started with the basics, noting that The Witcher 3's economy is based around money, or rather the concept that money is simply anything in the game that can be traded for something else.

"I had specific goals for the economy," said Steinke. "I wanted players to need money for purchasing food, ingredients, and upgrades, to explore the world around them for new items, earning money from combat, and collecting loot along the way. I wanted them to buy better items to improve their stats. Additionally, I wanted these items to cost more, so that players felt like they were earning lots of money by the end of the game. To visualise these goals, I sketched out a higher-level state diagram to illustrate the system interactions. Defining system interactions in this way, it's easy to see what kind of relationships created between the player and the economy."

Steinke's simple diagram (pictured below), which outlined the flow of money from one area of the game to the other, proved useful for mapping out potential gameplay paths. For instance, one of Steinke's goals was to have the player explore the world for new items. The economy facilitates this by providing loot from fights and random containers scattered throughout The Witcher 3's open world. Players can then use those items as cash to buy other items like better swords and armour from merchants without having to go out and find them.

Those newly purchased items then increase the strength of the players, allowing them to go out and fight higher-level enemies, explore more of the environment, and thus find more items.

This type of gameplay, which Steinke called the "cycle of spending," set out what he wanted the game's economy system to accomplish, but it didn't help with actually making it work. Without much to go off, Steinke started by trying to create prices for basic items like herbs, junk, and books, but he soon found himself simply guessing as to what those prices should be. And then what about more complex items like swords and armour, which had important attributes for use during combat? To help figure it out, Steinke created a formula that calculated attributes like how much damage, defence, or healing that each item provided, and he placed them into an overall combat rating could be used to rank other items in the system.

"To make the data more meaningful, I organised the list in into inventory items and sub categories that best represented their use," said Steinke. "Filtering each range of data for things like the floor, average, and ceiling values, I was able to quickly evaluate the relationships between the category's ability, its price, and how each range compared to the others. This led to a new set of rules and guidelines that specified how each category should be evaluated and adjusted compared to the others. For example, I wanted the steel swords to range from rusty and cheap, to gnomish, and expensive. But I also knew that they should remain less expensive than the steel relic swords you could find."

Steinke set about blending the sub-categories into nine generalised categories, allowing him to determine the final weighting for damage and the range of prices for each item. To test if it all worked, he used polynomial least squares (a form mathematical statistics) to chart each category's price progression. The resultant curve (pictured below) showed the rate at which spending was increasing as the quality of each item approached the category's ceiling value. The initial curve showed that at the lower end of the scale, even a small increase in quality generated a large increase in the item's price—not ideal when trying to make an accessible video game.

"Because The Witcher was so grounded, I had this impression that we needed to feel grounded as well," said Steinke "The economy needed to feel poor, and you needed to feel challenge and need to work for what you earned. But I also wanted to know that items would increase in value so that, when I reached the final relic sword, it felt like I was earning a lot of money and that it was really worth the effort. With these goals in mind, I started to tune curves in a different way, one that reduced the rate of growth until the end of the game, where relic items would continue to increase greatly in value."

While these tuned curves helped to balance the economy, they had other practical uses for game development too. By pre-calculating the coefficient and storing them in a table, Steinke was able to procedurally generate the data at run-time, allowing for an infinite set of points that fit the curve exactly, and for automatically generated content. This eliminated bugs and allowed any hardcoded values to be removed from the game, a process that Steinke says dramatically reduced load times and decreased the footprint of every item in memory. With guesswork removed from the economy, every item in the system was now consistently balanced in relation to other items.

This also allowed for the division of each category into specific level-based requirements, which meant that items could be automatically distributed throughout the world depending on the current level of the player. This applied to NPCs too, with each of them being dynamically equipped with armour and weapons that kept combat challenging. But while this system worked well, it didn't take into account another gameplay system that had the potential to dramatically change the economy: crafting.