The wiki will be unavailable from 7am until 9am on Tuesday, 22 August, 2017.
Child pages
  • Expert-Fuzzy Combination
Skip to end of metadata
Go to start of metadata

The final weapon selection AI algorithm combines the best attributes of the Expert System and Fuzzy Logic solutions to create a more advanced bot behaviour.

Combining the Expert System and Fuzzy Logic

The greatest strength of the Expert System is its ability to differentiate between the three target types: Player, Heatseeker Missile, and Nuclear Missile. This allowed the bot to deal with the more dangerous nukes more effectively, but at a cost of not always using the ideal weapon against other missiles or the player. It was also easy for a new player after a few tries to outsmart the bot as the rigid rules make it predictable.

The greatest strength of the Fuzzy Logic is its ability to effectively combine information about the distance and speed of the target, which generally helps with the aiming. However, its major failing is that it can sometimes use an inappropriate weapon on a target, such as the gravity pulse on the player ship (which is so heavy it barely moves), meaning that the player will not be fired upon in the region. Crafty players therefore can stay in this region and leisurely shoot at the bot without being shot back at.

By combining the Expert System and the Fuzzy Logic, all of these failings can be eliminated whilst keeping the strengths of both at only the cost of slightly increased complexity. To do this, the inference engine of the Expert System and the membership functions of the Fuzzy Logic are kept intact. The main change is that the Expert System ruleset is replaced with 3 Fuzzy rulesets, one for each type of target:

This is a simplified version of the full code, which can be found on the Bot Code Page.

Analysis of Performance

Behaviour when attacked by Heatseekers


The video to the right shows the operation of the above weapons selection behaviour when the bot is confronted by a barrage of Heatseeker Missiles. Heuristically, it is known that the best tactic against such a wave of missiles would be to initially counter with Dumbfire Missiles when the Heatseekers are at long range (as their splash damage has a chance of knocking out more than one). Then when the Heatseekers get closer, a switch to the Minigun is desired to be able to pick them off one by one. Finally any Heatseekers that get past the Minigun will need to be gravity pulsed away.
This is approximately what happens in the video, whilst the bot is unlucky not to hit any of the Heatseekers with its initial counter-missiles, it does have one lucky move where a Heatseeker is pulsed backwards into an Asteroid where it detonates. The bot manages to stop all of the incoming Heatseekers, showing an improvement over the individual Expert System and Fuzzy Logic approaches.

Behaviour when attacked by a Nuke


The second video shows the response of the bot to an incoming Nuclear Missile. The ideal method for dealing with a nuke is known heuristically to counter at long range using Dumbfire Missiles and then switch to Minigun at mid to close range. There is no point in using the Gravity Pulse as a nuke detonated away from the bot still does a lot of damage. There is also no reason to take the speed of the nuke into account, as the minigun is just as effective on fast moving missiles as it is slow moving ones (only a single hit is needed).
In the video, the bot fires missiles at the nuke and then switches to Minigun a short time later, showing that it is close to the heuristic ideal.


The ideal anti-Player heuristic approach is similar to the Nuke, except that speed is taken into account when it is mid-ranged from the bot. As the player has much more health than the Heatseeker and Nuke, it is preferable to use missiles as much as possible, as they do significantly more damage at mid-ranges than the Minigun - but only if they detonate on or close to the player. This means that missiles should only be used at mid-ranges when the player is travelling slowly, which is where the two 'andmethod' fuzzy rules above come in.
The two videos below show the difference in weapon selection when the bot is confronted with a slow or fast moving player. In the fast video, the bot abandons missiles and starts using the Minigun when the player is much more distant than in the slow video. This shows an efficient use of weapons, as the slow moving player is bombarded with missiles, whilst the fast moving player takes a lot of damage from the Minigun bursts.

Behaviour when attacked by a slow-moving Player
Behaviour when attacked by a fast-moving Player


The main objectives of this project were to demonstrate the use of AI to create a bot behaviour that looked intelligent, wasn't unfair, but created a challenge to the player. The combined Expert/Fuzzy weapon select system fills all of these criteria, as it makes the bot difficult to destroy, but not impossible; only by attrition or clever distractions can the bot be brought down. There are no obvious exploits that will let the player have an easy shot on the bot. It is difficult to imagine ways for the weapon selection system to be improved from this benchmark - although extra Fuzzy inputs, such as the health or orientation of the bot, may improve performance.

An additional triumph of the system is its modular nature, making it very easy to add additional rules for when the game is expanded in the future with additional target types and weapons.

  • No labels