With the next generation of PHP games using Ajax, the developer can afford to allow better user interaction with battling and Non-Player Characters. Some work can make a game seem more life-like and harder for the player to figure out.
For AI usage, testing and CPU, memory, and storage issue might sway developers away from the more advanced techniques. Not every problem needs a neural tree or genetic encoding for the solution and would be better served with a little bit of creative engineering with traditional means.
Traditional methods have the disadvantage of handling only a known set and can’t be trained for unknown habits that users might exploit. Calculations have the disadvantage of reverse-engineering and possible float bugs. So it would be useful to research AI methods to handle some problems.
The following is a list of problems and possible solutions for current and future PHP games. It is my goal with a few projects to see just how much can be accomplished in the field of online browser PHP games. Another focus is to see how much of a cost is added by using AI.
Problem 1: Calculating Distances in Real Time
Description
There are games that have you wait on moving objects across distances. The traditional approach has been to just use a set calculations which is easily figured by the player. The paths through enemy territory, which would otherwise be avoided (unless initiating a battle) are passed through in all instances.
Solution
There are path finding algorithms, such as Dijkstra, A*, and so on that could be used to accurately find the distance around enemy territory and other blocked locations, say a black hole.
Little can be given on the speed of large proportions, however small sizes are quite fast (logically of course). I plan on doing tests are larger sizes, such as 10k fields and 100k fields, when the classes are passed the testing stage.
There is a completed example for which to work with. My implementation is a lot different and not completely finish.
Problem 2: Enemy Behavior – Shifting Strategy
Description
The problem I’ve came across in RPG games is that the monster just pounds you with randomized attacks. It would make more sense for the monster if it changed its attack pattern for when you are low on health during the start of the battle or grow weaker. It should also try to prepare for spells and try to block attacks whenever it is low on health or run away.
Solution
Giving the enemy life wouldn’t all that difficult to do with traditional methods, but it would require a whole lot of conditional statements. A better method if it could be afforded, is to use Fuzzy Logic or at the very least finite state machines. Fuzzy Logic does require a lot of math and knowledge of set theory (or books and other resources that offer that information instead
).
Problem 3: Enemy Behavior – Learning
Description
How fun would it be that along with the enemy shifting it’s behavior it evolved in it’s technique? If the player is more inclined to use physical attacks, the enemy would start using physical blocking and spells for which to minimize the effects of physical attacks.
Solution
This can also be done using the traditional methods, but it would also be a very long list of conditional statements. A CPU extensive approach, but neater would be to use either genetics or neural networks for the learning. You could also spend time teaching the enemies yourself before the game goes live. Having the game available to what could be a massive amount of people would allow the enemy to well adapt to the players differing strategies.
Problem 4: NPC Interaction – Dialogue
Description
While not important in all games (should be anyway), it would be nice in RPGs, if you received your some of your missions from talking with NPCs. Say a NPC is missing a child and needs for you to search for the missing person. Most of the time, that discussion is fixed and scripted far before hand, and in most computer games as well. The difference is that in PHP games, there is no disconnection between the possible missions and which NPC gives the mission. It is that NPC gives that mission and nothing else.
Something else would be for NPCs that don’t have any missions to give. What about them? I would rather have them be a little bit more intelligent than old 2D RPGs, and have an open discussion depending on how far along you are and if you choose good or evil side. It would get pretty old to have the conversation with the NPC go on longer than 30 minutes or 10 minutes.
Solution
Very intelligent developers and scientists have already developed and worked on this for more than a decade. There is already an PHP library for which to use it in an application. So really, the only thing the developer has to do is spend time writing for which the library will use. It will require work, however not as much as the time it took to write the library in the first place. It would also add that special touch that other games wouldn’t have.
References
- AI Game Programming Wisdom 1
- Data Structures and Algorithm Analysis in C++. Pgs 339-346.
Possibly Related Posts:
- Game Engine Development and Open Source
- Plans for Base CMS
- Bullet: E-Book Library Management and Content Server
- Using ZendFramework 2 beta1 For Directory Project
- Project Plans
Interesting post.
Perhaps AI isn’t as interesting to that many people.
AI can be applicable to non gaming usage. It would take time and somewhat intelligent person to find those usages.
Personally I was a “conditionals” person myself until Santos turned up talking about AI. Since then I’ve converted and AI algorithms definitely have their place for PHP games. Pathfinding was the straw that broke the conditional’s back. I’ve seen pathfinding implemented in several PHP that relies on brute force matching – it’s processing intensive and with 1,000 comparison points it quickly starts to create large bottlenecks and processing time costs. True AI pathfinding on the other hand is a far more elegant solution – the math can be hideous but it’s benefits are quite obvious once you look deeper…
Under problem 4′s solution you mention briefly a php library that can be used for NPC dialog. Well I’m not familiar with all the librarys. So I was currious if you could tell me the name of that Lib. Anyways willing to do the research myself after that. You can email me or AIM Crank2003.
http://sourceforge.net/projects/programe/ is what I was referring to in the post.