quote:
Original post by Infinisearch
EDIT -What exactly do u mean by 'tick'
By "tick" I mean the minimal unit of time in the game. For instance, attempting an action takes one tick. A single turn in a turn-based game is a tick, while in a real-time game, a tick probably amounts to a single frame of the animation.
Off-screen NPCs do need processing, I actually make no distinction between onscreen and offscreen NPCs. You could make that distinction though, if you built your game carefully enough. Really, all that matters is what the player sees (or better "perceives", because you could have a sense of smell and sense of hearing in the game as well). If you can make everything else up as you go along, you're fine! That really limits the amount of processing that you have to do. However, doing it correctly is hard, so for now, lets just say that it's a "living world", and everything goes on around you, regardless of you being there or not.
Figuring out what is "in" your perceptual range is not really an issue with regards to CPU usage, because it has to be done for ALL forms of even remotely intelligent and realistic AI. There is nothing more annoying than the bot-that-sees-through-walls, because it does not take into account perceptual range.
What do we need for certain? Two types of objects are in the system: Active Objects (like the NPCs) and Passive Objects (like the Diamond). The first optimisation is to only look at the world through the eyes of the Active Objects. They are making our world change, without them, nothing would happen. So, we HAVE to do something for each of the Active Objects for every "tick" of the game. I'll say turn from now on, instead of tick - simply put, each active object gets to take one turn in one turn of the game.
Each Active Object must have a goal. If it doesn't have a goal, it won't do anything, and would then be a passive object. Goals can change, but for now, just assume there's only one goal to reach. When it's the Active Object's turn to do it's processing, it wants to achieve its goal, or at least attempt to advance towards it.
One way of doing so (the way that seems most "logical" to human reasoning, because it's how WE work), is to examine everything that you can perceive (and check your memory, but lets say these active objects don't have memories, they are dumb), and see if there is anything there that will help you achieve your goal. The problem with this reasoning, is that each active object must have a huge database of objects that can occur in the world, and what they are good for. This database has to be different for each NPC, because not everyone knows everything. It also makes it hard to deal with "drop-in" objects, by which I mean objects that you add to the game later, when you've already shipped it to your customers. If you only have apples and oranges, and suddenly you decide to add bananas, then you must have had the forethought of including a "food" attribute in the game, or none of our active objects will realise that you can eat a banana.
The "food" attribute is really an affordance, one that says "You can eat me". Using the attribute makes life hard though, because a hungry Active Object will have to check all the objects around it to see if they have the food attribute. An object cannot "hide" its food attribute either - for instance, if a Caveman from the northern wastes was hungry, he probably should not recognise the banana as food. With affordances, and a simple "geography" or "culture" attribute in an Active Object, that's easy. The Banana would check to see if the Active Object's geography allow it to know that a banana is food. With simple attributes, the Caveman would have to "know" that it "doesn't know" the banana is food. That means, it had to know about the banana beforehand, which it didn't, because you only introduced it in Service Pack 1 (
).
One way of solving it would be to add the bananas to the Active Object databases when you install Service Pack 1, but only add the bananas to the databases of Active Objects that are supposed to know them - but that's a lot of additional data which is redundant, because a banana remains a banana, regardless of whether you know about it or not.
Hrm, I don't know, perhaps I should make a detailed design of what I'm thinking of, and try to implement it!
Edited by - MadKeithV on January 23, 2002 7:15:23 AM
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.