Using Fuzzy Logic to Control a Videogame Defenseman


Fuzzy Logic Primer

Fuzzifying Hockey

FFLL API and Spark!

Rule Generation

Final Results


Contact Me

FFLL API and Spark!

Before I can discuss generating rules for this control system, I have to mention the API and helper applications I used for this project.

In my own education as a software engineer, I've discovered a common roadblock in learning. Often, I've read about some great theoretical concept in a textbook, but when I try to apply that concept in an application I get stuck. Why? Because the concept is hard to translate into real, usable code. I'm talking about either Java or C++. Most of the time, you're left thinking it'd be great if someone had previously written some API or library for you to use.

Fortunately, some headway has been made in this area in terms of fuzzy logic control systems. There is an open source project called the Free Fuzzy Logic Library. It's a Windows API that allows you to quickly set up all you need for inserting a fuzzy logic control system within your own applications.

You define your entire fuzzy control system enviroment (inputs, outputs, membership sets, defuzzification method) with a text file called an .fcl file. There is one .fcl file for every output you want controlled by fuzzy logic. The beauty of this is that you can make adjustments to your control system without re-compiling your code. The API simply reads the .fcl file(s) everytime the program runs to interpret what type of fuzzy control you want.

An invaluable companion application to the FFLL API is the Spark! Viewer. This Windows application reads in .fcl files as input and allows you to see your fuzzy control system in action even before it gets dropped into your own custom application. In the Spark! Viewer, you can vary inputs by dragging sliders and see the resulting defuzzified output in real-time. Using this application you can tune your control system even before one line of application code is written.

While extremely helpful, I must point out that these two items are still very much under development and there are some limitations you should know about. The biggest limitation is that the FFLL API currently can't handle OR statements in the rule block of .fcl files. If you have a lot of membership sets in your system, you can wind up writing a lot of rules to make up for this deficiency. I encourage you to read the documentation because there are a lot of things you can theoretically do in fuzzy logic that might not be supported yet by the API and Spark!.