AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

fuzzify

fuzzify是Yuka js库FuzzyModule的一个重要方法,它将数值转换成模糊变量。

Syntax

fuzzify(value: number): void

Parameters

  • value: 一个数值,要被转换成模糊变量。

Returns

undefined.

Example

const fuzzyModule = new YUKA.FuzzyModule();

// 定义模糊变量
const distanceToTarget = fuzzyModule.createVariable('distance to target', 0, 100);
const shotAccuracy = fuzzyModule.createVariable('shot accuracy', 0, 10);

// 定义模糊集合与其隶属度函数
const targetClose = distanceToTarget.addLeftShoulderSet('target close', 0, 25, 50);
const targetMedium = distanceToTarget.addTriangularSet('target medium', 25, 50, 75);
const targetFar = distanceToTarget.addRightShoulderSet('target far', 50, 75, 100);

const poor = shotAccuracy.addLeftShoulderSet('poor', 0, 2.5, 5);
const moderate = shotAccuracy.addTriangularSet('moderate', 2.5, 5, 7.5);
const good = shotAccuracy.addRightShoulderSet('good', 5, 7.5, 10);

// 对distance与accuracy分别进行模糊化
fuzzyModule.fuzzify('distance to target', 73);
fuzzyModule.fuzzify('shot accuracy', 3.6);

//...做其他计算

在上面的例子中,我们可以对distanceToTarget与shotAccuracy变量单独进行模糊化,而不用一次性设置。

完成以上步骤后,变量的值将会自动转换为隶属于相应模糊集合的数值。例如,73将隶属于 targetFar 模糊集合。

Remarks

  • 该方法将提供的值转换为相应模糊集合中的模糊值。

  • 此函数将在对象上更改其状态。

  • 此方法不返回任何内容。

  • 该方法将出错,如果未使用fuzzyModule.createVariable方法创建一个名字相同的变量。