PDA

View Full Version : AI for NPC / Monsters



darnpunk
February 21st, 2009, 09:38 PM
Hi,

I've been doing some reading lately on game AI and wondering where to place the logic n decision making in an online game environment. For an offline game, the AI can be processed on the game client. However, after much thoughts I can't decide where to process it in an online game like mmorpg.

Since all users need to be in sync, I thought they should be done on the server. But it seems like it may be too heavy for server n also bandwidth. Then, I thought it can be done on the client and decided by a master player. But then who shnuld be the master player and can I trust the player's data?

Right now, I am really thinking how to sync NPCs and monsters AI without putting too much load on the server. This will be my first for AI in online games. Any thoughts?

Valaran
February 21st, 2009, 10:06 PM
I'd have to say it has to be controlled by the server, there are to many security risks any other way in my opinion. And somehow I doubt it would be that much of a load on the server, I mean, its all a matter of numbers. If its an mmo you're developing, what's your guestimate on amount of players? All you have to do is limit the amount to allow for the server to handle it.

If your estimating a lot of players, split the workload on multiple servers.

tapioca
February 21st, 2009, 10:38 PM
an easy way to tell where an mmo does it is by the lag. if enemies keep moving while your connection is lagging then it's calculated on both client side and server side and they just sync up the AI and random number tables, but if enemies freeze when your connection is lagging then it's entirely server side. i'm pretty sure most mmo's do it server side and most multiplayer lan games do it client side.

darnpunk
February 22nd, 2009, 01:32 AM
Hi,

Thanks for your replies. I was thinking of using fuzzy logic to determine what the AI should do. The game I am building is isometric based. Does this mean the server needs to be able to calculate tile distances to determine if the target is far, very far, near and very near etc?

Right now, I determine the distance by using pathfinding due to line of sight, linear and so on. If I were to put this over to the server, and have many pathfinding instances, I imagine it may kill the server? By the way, I am using A* pathfinding algorithm.

Am I putting this all correctly?

Favardin
February 22nd, 2009, 06:30 AM
Thanks for your replies. I was thinking of using fuzzy logic to determine what the AI should do. Just wanted to warn you: fuzzy logic is somewhat black magic -- it might work for your AI, but it might work as well not. I advise you to start with a state-machine for your AI, if you want you can then model the transitions with fuzzy logic (and if that does not work out you can try to find an alternative).


Does this mean the server needs to be able to calculate tile distances to determine if the target is far, very far, near and very near etc?Not only that: the server should host the WHOLE game logic. Have a look at MVC (Model View Controller) design --- and while I'm at design: be sure to plan your game very detailed up-front, otherwise you'll quickly run into dead-ends. Especially the communication protocol should be clear from the start!


Right now, I determine the distance by using pathfinding due to line of sight, linear and so on. If I were to put this over to the server, and have many pathfinding instances, I imagine it may kill the server? By the way, I am using A* pathfinding algorithm.You are probably thinking of the speed flash displays on these algorithms -- other languages (your ARE planning on using some other language on the server side, do you?) are much faster on that kind of calculations (Especially since you can parallelize a lot).
I'd recommend java for that kind of endeavor. It has very nice libraries for networking stuff and threads are as easy as it gets (that is: still not easy).

If the above scared you a bit: GOOD! You should be very aware of the fact that multiplayer-programming is NOT easy and massive multiplayer even less!

That said: I hope you succeed. And think about getting a team together (if you not already have one).

darnpunk
February 22nd, 2009, 06:50 AM
Hi Favardin,

Thank you for the feedbacks. Yes, I am pretty scared from what you said above. Actually, I am always scared whenever I begin a new project as I always think of the worst things each project can give :P.

I've had some experiences with SmartFoxServer and will be using that as the multiplayer socket platform. You are right, I plan to use Java on the server side. Hosting the whole game logic on server sounds really tough. I guess I really need a lot of luck.

As for AI, I will heed your advice and go state-machine first. With regards to MVC, am I right to say the server is the model + controller while the game client is the view?

Favardin
February 22nd, 2009, 07:06 PM
With regards to MVC, am I right to say the server is the model + controller while the game client is the view?

Yes, but that depends on your view of MVC -- I found that there are several different definitions out there, starting from the first one (that was, if I'm not confusing something, part of the language Smalltalk) to the current "thin-client"-web2.0 definition (where there's virtually no real, explicit controller). So you should probably not cling to much to some paradigm, but see what works best. I find it especially hard to pin down the controller and their relation to the model -- perhaps there are other people here that have more experience with that.