I am currently in the planning sta开发者_开发问答ges of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it. I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck.
I intend to run multiple server instances with 200+ persistant NPC entities that I will need to update. Most action is slowly roaming around based on player movements/concentrations, and attacking close range players...(you can probably guess the type of game im developing)
Will your game be turn based or real time?
Either way, I think you have 2 options to look into. One is to use the Cron feature so you can schedule NPC updates at regular intervals, the other is to stick a "update NPCs" task into the Task Queue every time a human player moves.
If the game is turn based then it would probably be best to avoid the Cron task and just update the NPCs every time the player moves. I'm not sure how big of a map you are planning on but you may consider even having the player object find the NPCs that are close to it and call their AI routine. That way NPCs that are out of range of a player wouldn't move at all which may save on resources. Not sure if that matter though.
Bear in mind that you can also break up your updates into multiple requests (internally): do a bit of work, redirect to the same handler but different state; do more work; etc. (I'm failing somehow to comment on Peter Recore's answer, which is where this really belongs.)
I see that the free service only allows 100k task queue calls/day, so 1 task/NPC would probably use up your resources way too fast. Cron job to do some work/create task queues to update NPCs in appropriately-sized groups?
Anyway, just some thoughts; good luck.
精彩评论