Wednesday 25 January 2012

Event Manager.


To get information between different parts of a game, you may use events and a event manager, and event is anything happening in the game, that something else might have interest of, this could be shots fired, units dying, change in score, a unit turning visible, so about anything.

The main goal is that, once something happens, you inform all with interest that it happened, and do it once, instead of a system where you for instance save all events and loop trough them for each and every unit and deciding if they are relevant, the second one is much faster to set up, but requires a lot more prestanda, and a good event system can be used and reused for anything.

So thats where I am going today, trying to get the events up and running in a good decent way.

Tuesday 24 January 2012

AI coding.

I will cover some topics topics for the unknowing, and ofcourse from my point of view and how I see it, wouldn't be fun otherwise.

First of all
AI:
Most people know that AI stands for artificial Intelligence, often called Artificial Stupidity, or in some cases "MOM!!! The computer is cheating!".

The ideal AI is made with the goal to behave like a person expects another person to behave. A quite hard task since a computer is where good a fixed states of rules, and reasoning but not so good with random behaviors or adapting to change. A person on the other hand is very good to behave randomly or eradict and most are atleast to some degree equpied to adapt to changes. Most FPS games, that are by design mostly skillbased, fast triggerfinger and good aim will make you better, are still beaten by a wellwriten AI, this is because the AI can see allways at once, it can snap it's aim to the first microsized piece of hitbox that appears, and it's aim is allways perfect.

Some will cry "I have seen the bots for CS, they sux lolollooloololoo HAX!" and yes they often do, because people want to be able to win. But people call this cheating because a human can't see all ways at once, I am not saying that the AI is looking trough walls, that would be cheating. It's more the fact that the AI might turn a full 360 degrees, register everything thats in it's field of vision and react to it. And it can probably do that, based on the engine, say atleast 30 times a second. So as field of view goes, the AI will register anything visible from it's point of view 30 times a second, I have a hard time writing this, with the screen in focus and trying to find the coke bottle on the floor at the same time. (it was in the living room)

Add on top of that the computers increadible power to calculate things in 3 dimensions, how did you think any game was represented, (one an average today I would bet over a million triangles worth of data are rendered per frame in a modern game) and an AI only need one ray, to know where to aim and shoot prefectly, some more work comes with grenades and slow moving projectiles like rockets and other things with an area effect.

So there are some decisions to take regarding to the AI, do we want it to be best at somthing, do we want it to adapt, do we need speed or strength, how much can we simplify without it being notised.

Simplification is the best friend of a AI programmer, and data that is ready to act on at decision time, the fewer things that needs to be updated, calculated and changed, the better.

In my current project since the AI is managing both your troops as well as the enemy, (the only different is how the orders are issued), makes it possible to cheat as much as I want, since no side will get an unfair advantage, but at the same time I need to make sure that it balances out with the decisions the player does get to make.Weapon layout, skills of team members etc, as well that it should looke esticaly pleasing in some way when you actually do see combat, in many cases I could just do some random rolls and be done with it, but since any point can potentialy be seen at any time it's better to do it well, and do it right.

Current Project.

My current project is a Agent based RTS, where you give orders but don't control the troops, feedback from the enivorment is provided from your troops when they return, if they return.

Now most people are thinking "if I only gett feedback when my troops return, what will I do when they are away?", well your base of operation will allways have a realtime feed, and all units moving in it's range will be visible (if they are friendly, or if they are not sneaking). Additional to that, you may request the building of outposts, as well as request construction of landlines between outposts and your main base, resulting in real time feed, or atleast slightly delayed feedback from your outposts. An outpost can be any type of building you might construct like guardtowers, forts, farms and mines. The decisions if you want to landline somthing is simply a question about cost.

Squad managment and orders becomes more important if you can't actually follow your squad in realtime. So you will have the possiblity to prioritising the layout of the teams gear, where greater armor and weapons might give you an edge in a fight, but the weight might prevent them from retreating if things go south.

The main problem being, if a unit dies, the gear drops at the units current position, meaning, if you send a highly equiped team and they are outmaned, knocked out by gas, sneaking enemies, or just in someway dies, the gear will drop at that point, worse, if no one make it back, you won't miss your team untill they miss a planed radio contact (if they had a radio) or you expected them to come back. You won't even know what prevented them from coming home. It can also be so simple that the radioguy is taken out first, and the rest of the team is pinned and can't call for backup.

The game itself might suck since it's kind of unproven ground, no controll, and no feedback without reports, but it might be intresting and require a new set of strategies.

At the moment I am working on behavior trees to get the AI working, previously I've had a hardcoded leader, and hardcoded followers, and now I try to merge them, as well as allowing them to dynamicly pick a new leader if the old one dies, or if part of the team is cut off.

So far it's going quite well, but since the tree and original behaviors are quite different, it might take some time to sort things out. First goal, to place on AI that designate himself leader and try to navigate somewhere, after that, adding two AIs and make them decide who's leader, make the leader plot a course, and the follower to follow him.

I have high hopes.

A New Blog.

A friend of mine got annoyed when I said that I don't have much over for twitter, he thought it was a great place for me to post updates about my projects and how development is going.

The thing is, I am seldom a person of few words, and restrictions in what I can post just pisses me of. There is nothing worse then being in the middle of telling something, and suddenly have to remove a space press after a . and squeezing words together to fit the last word you need.

Rather since people think I am spaming them on MSN, I got a blog rolling, I have tried this now and again, but it usualy ends bad, that not being said it might be a good idea "THIS" time.

First of all, the main goal is to try to post something once a week, probably in the area of game devlopment and code. But one can not tell of things turn out in the long run, so this is the first post, and will probably soon be follwed by another covering what I am currently working/pokeing on.