Website

Please visit www.kyncreations.com for more official info on my projects!

Wednesday, May 25, 2016

Procedural Generation



No Man's Sky had a hype train like no other, but only because the idea of procedural generation made the world tantalizing.

Procedural generation in video games means that the audio, visuals, the structures, and even the gameplay can be created at runtime by code.

There's no need for expensive tools, hundreds of hours of work in pipelines that get clogged regardless of effectiveness or efficiency, or workaround solutions to simple problems.

The idea is that someone with a cursory knowledge of a concept, for example - stone - can write code and use mathematics to create this:
http://procworld.blogspot.com/
 Computer programming is largely language and math-based. That means we can reduce extremely large systems and environments down to their simplest form. Don't let the word 'database' intimidate you, because they're just rows and columns of information, just like a regular excel spreadsheet. Those cells of data can be interpreted into something as simple as the size, orientation, color, and roughness of each of the stones shown above.

Even something as complex as animating an animal can be solved using a procedural approach. The model composing that animal has to be rigged with joints which represent bones. Each of those bones only has a certain range of motion, and then has muscles attached to points, which further modify how the bone can move. After the entire model is fully rigged, a bit of code can determine how that animal walks, runs, turns, etc. based on how those bones and muscles interact.

So instead of dumping money into arbitrary problems that we can't solve with the tools that are currently popular, why don't we dump some money into solving those problems with new tools that were either previously underrated, misunderstood, or simply undiscovered!

Tuesday, March 15, 2016

Solving the Problem of Simulated Time and Space

Part of the reason why I have waited so long to build a rough prototype of A Village In Time is because I haven't decided how I want to solve the problem of simulating time and space for the medieval world. Speeding up the time is an obvious and common choice developers use to make sure we can play games without absolutely losing all of our time doing so.

For example, in The Sims 3, players get the option of choosing how fast the sims age (ranging from 25 to 960 in-game days). Each in-game day, played on normal speed, equals roughly 24 minutes. And anyone who's played the game knows that 16 of those minutes is spent in fast-forward, so let's just say 10 minutes. That means players can choose how long each game will be based on how long their sims live, effectively determining how much time they'll spend in a single game.

Personally, I like this model, and will probably emulate it in some way. The fundamental problem still exists, however, that simulated time does not convey real actions and movement. The Sims 3 game-play includes Sims that will shower for up to 6 hours, require at least half an hour for a tinkle, or clean the sink for 3 hours. Regardless of the actual math, the principle concept is that the player loses valuable playing time to poor simulation balancing.

Take the example of Banished: each villager lives 75-90 seasons, or roughly 19 to 22 in-game years. Each season is roughly 25 real minutes. Players can control the time scale up to 10x, and so 1 in-game year can equate to as little as 10 minutes of real time. With that kind of time scale, micromanagement becomes impossible and effectively so does expanding the settlement. I need to slow time back down when a trade needs to happen, mark resources for collection, or place plots for construction.

I also like this model, so I have two options. So why not both? Have the player choose the lifespan of villagers at any point in the game via the options menu, and then also control the time scale for precise periods of management and overview. The problem with going with both is that I feel put off by how fast villagers could and do travel over these periods of time.

Simulating weeks, months, seasons, years, and the human lifespan means that a finite number of actions can occur during a specific period of time. Changing the walk/run speed of the villager drastically changes the number of actions, which can drastically imbalance a real-time strategy game. So now it's no longer a question of how long the player feels comfortable playing (since we've relegated a player's general play time to anywhere from 20 to 90 minutes), it's a question of how many actions does the player expect out of their villagers in that time.

Let's be clear here. I'm not talking about actions per minute in the sense of competitive play. Demoting a game to such a high stress level is the opposite of the point of playing games.

Look at Age of Empires - a clean real-time strategy, based in the middle ages, with almost no relation to simulated time. No day/night cycle, no seasons, no years, no lifespans. Simple, effective.

But I have to have simulated time. I can't have all the details I want without sacrificing either player time (dangerous, because games that take too long to play don't get popular), or player satisfaction via villager speed and number of actions per time cycle.

So let's say I max out the average play time: 90 minutes. Each villager has a lifespan of about the same. Okay, next let's determine a good number of actions a villager can do per minute. I'll define a villager action by moving to a destination and then picking an object up. My environment is measured in meters for simplicity. I'm assuming a villager can move at least 2 meters per second. So now my actions are determined NOT by time scale or villager life expectancy, but by distances traveled. A villager assigned to pick up and drop off an object at a distance of 30 meters per trip means that they will complete those tasks 4 times per minute.

That's slow... real slow. The obvious solution is to speed up the villagers. Let's assume they run everywhere (like in most MMORPGs): 7 meters per second. Now that same round trip can be done 14 times per minute, and that's much more reasonable.

TL;DR - Simulating game time means taking liberties with simulating unit speed and/or stamina.