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

updateDegreeOfMembership方法说明

简介

updateDegreeOfMembership()是Yuka js库中TriangularFuzzySet类的一个方法,用于更新模糊集合中某个元素的隶属度。

参数

updateDegreeOfMembership()方法接收两个参数:

  • value(number):要更新的元素的值。
  • degree(number):元素的新隶属度。

返回值

updateDegreeOfMembership()方法没有返回值。

示例

假设我们有一个三角形(1,2,3)的模糊集合,并且我们想要更新元素2的隶属度为0.8。

import { TriangularFuzzySet } from 'yuka';

const fuzzySet = new TriangularFuzzySet(1, 2, 3);

fuzzySet.updateDegreeOfMembership(2, 0.8);

实现细节

updateDegreeOfMembership()方法通过修改degreeOfMembership数组中相应索引的值来更新元素的隶属度。具体实现如下:

updateDegreeOfMembership( value, degree ) {

    const index = this.findIndexForValue( value );

    if ( index >= 0 ) {

        this.degreeOfMembership[ index ] = degree;

    }

}

注意事项

  • 如果要更新的元素不在模糊集合中,则updateDegreeOfMembership()方法不会有任何作用。
  • 元素的隶属度必须在[0,1]的范围之内,否则会抛出错误。