fuzzylogic is a minimal and fast Fuzzy logic engine for games. When coding the AI of a game entity, for instance, developers usually organize rules and thoughts using if statements. If a condition is evaluated to true, e.g. enemy is close, then the actions within the if block that holds that condition will be executed. This pattern usually produces crisp and robotic results, since all conditions are very specific questions containing just a single answer (true or false).
This library enables the use of Fuzzy logic to enhance AI development. A developer can connect condition values, e.g. distance to the enemy, with a fuzzy module. The whole operation can be customized using different ranging function. The fuzzy logic usually overlaps the results from different conditions, producing convincing results. E.g. An entity must shoot using weapon A if an enemy is close, but it can shoot using weapon B, occasionally.
Fuzzy rules can be defined using natural language, which helps to write better and advanced behaviors easily.
fuz=new Fuzzyficator(); manifold = new FuzzyManifold("Distance_to_Target"); var distanceStatusInput:FuzzyInput=new FuzzyInput(); manifold.input = distanceStatusInput; //Close would be everything(every distance) from 0 to 125 func = factory.create(FuzzyMembershipFunction.LEFT_SHOULDER, "Close", 0,25, 125 ); //Medium distance would be from 25 to 300 func = factory.create(FuzzyMembershipFunction.TRIANGLE, "Medium", [25 150 300] ); manifold.addMember(func); //Far would be everything from 150 to 400 func = factory.create(FuzzyMembershipFunction.RIGHT_SHOULDER, "Far", "150, 300,400","," ); manifold.addMember(func); //You can add function base points with separator, or like array  or like string with separator. rule = new FuzzyRule( " IF Distance_to_Target IS Far AND Ammo_Status IS Low THEN Desirability IS Undesirable "); fuz.addRule(rule); rule = new FuzzyRule( "IF Distance_to_Target IS Medium AND Ammo_Status IS Loads THEN Desirability IS VeryDesirable "); fuz.addRule(rule); rule = new FuzzyRule( "IF Distance_to_Target IS Medium AND Ammo_Status IS Okey THEN Desirability IS VeryDesirable "); fuz.addRule(rule); fuz.Fuzzify(); fuzzyManifolds = fuz.Defuzzify(DefuzzificationMethod.CENTROID); trace("OUTPUT COG:" + FuzzyManifold(fuzzyManifolds["Desirability"]).output);