Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
using AForge.Fuzzy;
public class fuzzy : MonoBehaviour {
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
// initialization of the Fuzzy Inference System
void InitFuzzyEngine()
{
// linguistic labels (fuzzy sets) that compose the energy level// треугольники
FuzzySet fsLow = new FuzzySet("Low", new TrapezoidalFunction(0, 0, 20 ));
FuzzySet fsMedium = new FuzzySet("Medium", new TrapezoidalFunction(0, 40, 60));
FuzzySet fsHight = new FuzzySet("Hight", new TrapezoidalFunction(40, 100,100));
// linguistic labels (fuzzy sets) that compose what to do// треугольники
FuzzySet fsRun = new FuzzySet("Run", new TrapezoidalFunction(0, 0, 20 ));
FuzzySet fsDefend = new FuzzySet("Defend", new TrapezoidalFunction(0, 40, 60));
FuzzySet fsAttack = new FuzzySet("Attack", new TrapezoidalFunction(40, 100,100));
// input lingvistic variables for energy
LinguisticVariable lvEnergy = new LinguisticVariable("Energy", 0, 100);
lvEnergy.AddLabel(fsLow);
lvEnergy.AddLabel(fsMedium);
lvEnergy.AddLabel(fsHight);
// input lingvistic variables for health
LinguisticVariable lvHealth = new LinguisticVariable("Health", 0, 100);
lvHealth.AddLabel(fsLow);
lvHealth.AddLabel(fsMedium);
lvHealth.AddLabel(fsHight);
// input lingvistic variables for what to do
LinguisticVariable lvAction = new LinguisticVariable("Action", 0, 100);
lvAction.AddLabel(fsRun);
lvAction.AddLabel(fsDefend);
lvAction.AddLabel(fsAttack);
// the database
Database fuzzyDB = new Database();
fuzzyDB.AddVariable(lvEnergy);
fuzzyDB.AddVariable(lvHealth);
fuzzyDB.AddVariable(lvAction);
// creating the inference system
InferenceSystem IS = new InferenceSystem(fuzzyDB, new CentroidDefuzzifier(1000));
// rules
IS.NewRule( "Rule 1", "IF Energy IS Low THEN Action IS Run" );
IS.NewRule( "Rule 2", "IF Energy IS Medium AND Health IS Low THEN Action IS Defend" );
}
}
using System.Collections;
using AForge.Fuzzy;
public class fuzzy : MonoBehaviour {
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
// initialization of the Fuzzy Inference System
void InitFuzzyEngine()
{
// linguistic labels (fuzzy sets) that compose the energy level// треугольники
FuzzySet fsLow = new FuzzySet("Low", new TrapezoidalFunction(0, 0, 20 ));
FuzzySet fsMedium = new FuzzySet("Medium", new TrapezoidalFunction(0, 40, 60));
FuzzySet fsHight = new FuzzySet("Hight", new TrapezoidalFunction(40, 100,100));
// linguistic labels (fuzzy sets) that compose what to do// треугольники
FuzzySet fsRun = new FuzzySet("Run", new TrapezoidalFunction(0, 0, 20 ));
FuzzySet fsDefend = new FuzzySet("Defend", new TrapezoidalFunction(0, 40, 60));
FuzzySet fsAttack = new FuzzySet("Attack", new TrapezoidalFunction(40, 100,100));
// input lingvistic variables for energy
LinguisticVariable lvEnergy = new LinguisticVariable("Energy", 0, 100);
lvEnergy.AddLabel(fsLow);
lvEnergy.AddLabel(fsMedium);
lvEnergy.AddLabel(fsHight);
// input lingvistic variables for health
LinguisticVariable lvHealth = new LinguisticVariable("Health", 0, 100);
lvHealth.AddLabel(fsLow);
lvHealth.AddLabel(fsMedium);
lvHealth.AddLabel(fsHight);
// input lingvistic variables for what to do
LinguisticVariable lvAction = new LinguisticVariable("Action", 0, 100);
lvAction.AddLabel(fsRun);
lvAction.AddLabel(fsDefend);
lvAction.AddLabel(fsAttack);
// the database
Database fuzzyDB = new Database();
fuzzyDB.AddVariable(lvEnergy);
fuzzyDB.AddVariable(lvHealth);
fuzzyDB.AddVariable(lvAction);
// creating the inference system
InferenceSystem IS = new InferenceSystem(fuzzyDB, new CentroidDefuzzifier(1000));
// rules
IS.NewRule( "Rule 1", "IF Energy IS Low THEN Action IS Run" );
IS.NewRule( "Rule 2", "IF Energy IS Medium AND Health IS Low THEN Action IS Defend" );
}
}
Мне в ответ:
Скрытый текст:
ЧЯДНТ?
P.S. Метод с документации ( [DllImport ("PluginName")]) я вообще не понял и он не работает.