Sign in to follow this  
polyfrag

What/how to precompute

Recommended Posts

I need some ideas. And you are my infinite ocean of wisdom. This is for my retro-graphics 3D-tiled-world RTS/sim with economy. I have a 5 TB HDD and perhaps an AWS instance with 64 cores and I need to precompute something, but I have no idea what. The behaviour of the little beings might use some brute force precomputing, but I need a way to make them alive, or learning, in a way, to give them some high-level functions perhaps that have been evolved. I thought of precomputing rules for how they do their shopping and job searching, based on prices and distances (the only known things) to create a stable economy. This would be pretty difficult with brute force and non-chess like moves, but if the only decisions they're making is which job to work at now or where to shop or rest, and the low-level details like pathfinding are done by a linear subsystem, that might reduce the number of possible permutations. Let's say I have a set map with buildings on it that I use to train them, or a set of varied maps. It might still be too computationally demanding to achieve enough speed, if the units have to move and do collision detection along the way. This is why I'm for simplifying the sim to WarCraft II-like tile occupation and movement.

Share this post


Link to post
Share on other sites

What you need to precompute depends heavily on the design of your game.

 

Firstly plan it all out and don't plan to optimise at first, this is called premature optimisation and is generally bad.

 

After you have a prototype working, profile it with a profiler and find the bit that is taking up the most time and optimise it.

 

Generally things like pathfinding and AI benefit best from being precalculated as does static lighting in 3D and anything that can be represented simply as a constant. 

 

Let me know if this helps!

Share this post


Link to post
Share on other sites

Moving onto the path of pre-computing without knowing what you want to compute, and what you are going to do with the results, sounds like a bad move to me.

Possibly you will need your disk and cpu cores one day, but imho not until you have a clear idea of what you want from it.

 

I haven't yet wandered into the territory of AI very much, but one thing that struck me ever since I started studying games. You can fake a lot with very simple mechanisms.

If your beings need to go to work and do shopping, my first approach would be to let them do both things with something like

 

- find suitable places to work/shop nearby

- compute costs (distance, price, pay)

- add a little random

- pick best solution

 

Since you don't want to switch work every day, use a random with a low probability to decide when to re-evaluate current work/shop.

Share this post


Link to post
Share on other sites

With existing terrain with little player modification you can precompute routes (hierarchical nodes at road/street intersections or terrain areas on a more open map.)  

 

If you have multiple level map scenarios you can adjust behavioral coefficients for the different inhabitant behaviors to match each map  (preferences and difficulty thresholds - judgement data)

 

If the inhabitants too are largely static (player doesnbt cause many new ones to be introduced onto map), their occupations and daily schedules/mix of activities can be built up/formed organically --  ahead of time to match their map scenario.  

 

distance equals time - a resource needed for whatever activities are done

Share this post


Link to post
Share on other sites

Moving onto the path of pre-computing without knowing what you want to compute, and what you are going to do with the results, sounds like a bad move to me.
This, totally.

 

You can fake a lot with very simple mechanisms.
Also, consider two things:
  1. Precomputing is only a win if reading the precomputed data is faster than generating it on the fly. Mentioning "5TB HDD" implies that you have to expect something in the tens of milliseconds for access. That's a lot of time for a computer, even when it comes to AI.
  2. The best AI is not necessarily, and in fact almost never, the best AI. Wait, what? To understand this apparent paradox, consider the purpose of a game, and then reconsider the purpose of AI. A game that isn't fun is a crap game. The AI must be strong enough to be a challenge, but on the other hand you do not want it to be too perfect. A computer has no trouble beating a human in a strategy every single time[1]. But is this a game that said human will enjoy, and will continue playing? Surely not. Therefore, a "faked AI with simple mechanisms" may be not at all too undesirable.

 

[1]Indeed, I hate playing RTS games since the AI of every single RTS beats me every single time unless I set it to "very easy" or reduce simulation speed to 1/2. That's mostly because the AI doesn't have to bother scrolling around to find a particular unit. I'm still searching for a unit while the computer has initiated building three others, explored another dozen squares and sent harvesters on the way, and killed two units of mine. All simultaneously. I can't even click that fast.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this