Game Development Reference
In-Depth Information
mood = new LinguisticVariable("Mood");
mood.MembershipFunctionCollection.Add (
new MembershipFunction("Angry", 0, 0, 20, 40));
mood.MembershipFunctionCollection.Add (
new MembershipFunction("Indifferent", 30, 50,
50, 80));
mood.MembershipFunctionCollection.Add (
new MembershipFunction("Happy", 60, 90, 100, 100));
fuzzyEngine = new FuzzyEngine();
fuzzyEngine.LinguisticVariableCollection.Add(health);
fuzzyEngine.LinguisticVariableCollection.Add(shield);
fuzzyEngine.LinguisticVariableCollection.Add(mood);
fuzzyEngine.Consequent = "Mood";
fuzzyEngine.FuzzyRuleCollection.Add(new FuzzyRule(
"IF (Health IS Good) AND (Shield IS High) THEN Mood IS
Happy"));
fuzzyEngine.FuzzyRuleCollection.Add(new FuzzyRule(
"IF (Health IS Bad) OR (Shield IS Low) THEN Mood IS Angry"));
fuzzyEngine.FuzzyRuleCollection.Add(new FuzzyRule(
"IF (Health IS Moderate) AND (Shield IS High) THEN Mood IS
Indifferent"));
fuzzyEngine.FuzzyRuleCollection.Add(new FuzzyRule(
"IF (Health IS Moderate) OR (Shield IS Medium) THEN Mood IS
Indifferent"));
fuzzyEngine.FuzzyRuleCollection.Add(new FuzzyRule(
"IF (Health IS Bad) AND (Shield IS High) THEN Mood IS
Indifferent"));
}
function Update ()
{
}
Note
Defining Fuzzy Sets
Fuzzy sets are defined by four values representing the degrees of
membership of values at each quarter. These four values can be seen
in the MembershipFunction()s of Listing 5.21 . Sets are drawn from four
values given such that each value represents the x coordinate on a
quadrilateral and the respective y values are 0, 100, 100, 0. The x values
will vary among sets, but the y values are always the same. Figure 5.18
illustrates the sets associated with the linguistic variable Health.
Search Nedrilad ::




Custom Search