top of page

​  Language and Engine usage:

  • I used the Unity game engine because the game the AI was developed for was developed in Unity.

  • I used the C# language because again the base project was programmed in c#.

​

  This AI was developed as my BSc's final year project and dissertation using my Cube Wars project as a basis. The aim of the project was to test the effectiveness of an AI that uses fuzzy logic against one that uses traditional crisp logic. 

​

  Fuzzy logic is in essence instead of statements being true or false they can have varying degrees of truth. This is expressed with Fuzzy sets. With ordinary sets an object is either a member of the set or not, its in or out. With Fuzzy sets however objects have a degree of membership between zero and one to represent how much they fit into the set. The classic example of this is having a set of tall people, with crisp sets anyone above 5'10" may be considered tall and so is in the set, under that they are not in the set. However a fuzzy set of tall people may have anyone below 5'2" has a membership of 0, anyone above 5'10" has a membership of 1 and anyone in between has a membership value interpolated between the two, e.g. 5'7" gives a membership value of 0.625.

​

  Fuzzy Inference Systems (FISs) map inputs to outputs using Fuzzy sets. I used a Takagi-Sugeno (TS) FIS that categorised the game state into fuzzy sets and then used weighting rules and corresponding output formulas to calculate an final output. For example a TS FIS that calculates whether an individual is well suited to playing basket ball, given their height in inches and athletic ability on a scale of 0 to 10. It could use the above fuzzy set membership rules for tall people and another fuzzy set of athletic people to form weighting rules somewhat like these (given individual i):

  1. tall(i) and athletic(i)

  2. tall(i)

  3. not tall(i) or not athletic(i)

  If individual i had a height of 5'7" and an athletic ability of 4 those equations would evaluate to:

  1. 0.625 and 0.4 = Min(0.625, 0.4) = 0.4

  2. 0.625

  3. (1 - 0.625) or (1 - 0.4) = Max(0.375, 0.6) = 0.6

  Each of these rules would have a corresponding output formula that would take the form:

  • z = a * x + b * y + c

    • z = output.

    • x = height.​

    • y = athletic ability.

    • a, b, c = constants.

  The final output is computed using each of the weighting (w) values and the corresponding output (z) values. For this FIS with 3 rules the final output formula would look like:

  • Final Output = z1 * w1 + z2 * w2 + z3 * w3

                                            w1 + w2 + w3

​

  As explained in the above video my AI worked by calculating the overall goals for the AI's current turn. These overall goals essentially define what it most pressingly needs to do to improve its chances of winning. The AI then values all possible tasks it can perform. There are four kinds of tasks each valued by a TS FIS:

  • Attack Unit Tasks - One for each enemy unit, represents value of destroying it.​​

  • Capture Base Tasks - One for each unclaimed base, represents value of capturing it.​​

  • Conquer Base Tasks - One for each enemy base, represents value of capturing it.

  • Protect Base Tasks - One for each AI owned base, represents value of stopping it from being captured.

  The AI then checks which of its units can perform which tasks and values the assignment of each unit to each of the tasks it can do. It then uses those values to calculate a more accurate value of assigning said unit to the task by accounting for how close it will get the unit to other valuable tasks. For example if there is one unclaimed base near by to a unit and in the other direction there is a group of three bases that are close together but slightly further away from the unit. The close base seams like a more valuable assignment at first but if the unit is moved to a group of three it can capture them in quick succession making that group more valuable when accounting for follow up tasks to the one being assigned. A final more accurate assessment of the value of assigning a unit to a task is then calculated by accounting for how suited this unit is to the task compared to the other units that could complete it. The idea being most tasks it is pointless sending multiple units to do and if there is one task that many can perform then its best to send the most suited unit and send the others to complete other tasks. The value is also based on whether the unit is more suited to a task than the other tasks it could do, the idea here being to balance using each unit for the task its most effective at while using the most suited units for each task.

​

Takagi-Sugeno Fuzzy Inference System AI

Work

About

bottom of page