Leges Motus Progress: Simple and Fuzzy Logic AIs
Time has gotten away from me once again, and I have not posted a recent update on our progress with Leges Motus’ AI creation. First of all, the most recent code for Leges Motus is now on GitHub (https://github.com/jpfau/legesmotus), instead of SourceForge’s SVN. Secondly, we have been making significant progress on the AI creation.
We started with a very simple, deterministic AI, to test out our ability to make a completely player-less client. This was very easy, due to the design of the re-written client and logic code. The simple AI essentially works as follows:
- Find the nearest enemy we can see.
- Find out if we can see the enemy gate.
- If we are not on the enemy gate and we can see it, turn the gun towards the gate and then jump towards it.
- If we can see an unfrozen enemy, turn the gun towards them and fire (with some random inaccuracy).
- If we can’t do either of those, jump randomly (with a chance of jumping towards the gate, even if we can’t see it, in hopes of getting closer).
That’s about it. It’s simple, it looks a bit silly jumping randomly into walls, but it works. It can even win games against human players. But really, it’s just a baseline test.
The Fuzzy Logic AI is more interesting, though still not up to the level we will be trying to reach for our final AI. The system is approximately as follows:
- A config file specifies the ranges and edge functions for each fuzzy logic category/bin within that category. Example: dist_to_player.melee is somewhere around 0-64 pixels away, with dist_to_player being the category and melee being the bin.
- The categories are loaded, and put into a FuzzyLogic object. A FuzzyEnvironment is passed in each frame with the appropriate values set for each category.
- The FuzzyLogic passes the bin values into various Rules, which are constructed in a hierarchical structure (Example: two terminal bin values inside an Or rule inside an AND rule, all in a NOT).
- The Rules each output a float value, which is used to determine the importance of various actions or the value of various things. For example, a rule is used to determine which enemy player is most dangerous.
- The output actions are similar to the possible output actions of the Simple AI, but decided upon in a much more flexible and interesting way. This makes the AI seem less computer-like and more like it is making informed decisions.
We are also looking into making the FuzzyLogicAI switch weapons as appropriate to the situation. This could be slightly more difficult, since the weapon system was not designed to allow easy external determinations of weapon damage at a specific range, exact effects, etc. We will be considering how best to make these decisions general enough to work with any weapon setup.
Unfortunately, the FuzzyLogicAI is still unable to jump in a useful manner (other than randomly) except when it sees an enemy gate. This means that our next step will be pathfinding. We plan to store information about the reachability graph for each map on disk, and to load that into memory when the AI joins. This could have a lot of space/time tradeoff issues to look at, and we will then need to determine the best algorithm (probably A* of some sort) to find the paths through the map once the graph is made.
I’ll keep updates coming as we continue the AI work.