Miarmy Crowd Simulation Documentation (English)

Implementation

Step 1: Get Input Results

From input sentence content, we can let the engine calculate the results for this sentence, the result is an array, and the length of array is non-fixed, even can be zero.


A sentence of node, Red: input sentence

 
The sentence "someone in my sphere with angle" may return many results based on how many agents in the sphere range of current agent.

Also it might return nothing. (See Detection Range Sphere for getting the details the return values of this sentence)

Step 2: Fuzzy Logic for a Single Sentence Calculation (Sentence Active)

In the following picture, a single sentence contains an sentence content, a true range test and fuzzy values.


A single sentence in yellow bound, Red: input sentence Green: true range Blue: fuzzy values

 
Each sentence is composed of:

  • Input sentence: return a list of values based on sentence type
  • Test rule: ID, pre-operator, priority, inverse flag
  • Test range: the full true range without fuzzy blur
  • Fuzzy value for the start and end of test range, plus and minus

Firstly, the input sentence will return a list of values from Input Engine base on the information of agent itself and environment.

Then, we will get biggest one result value, we call it Input Result. Please distinguish it with the Sentence Active

Use the Input Result being input value and use fuzzy logic to test its active, this active is Sentence Active

Fuzzy Range

And the sentence contains a test range (or true range)

from -90 to 0



True range from -90 to 0 make sentence true

 

Then and a fuzzy value, such as 30, then turns out the fuzzy range:

  • from -90 to 0
  • Fuzzy: 30, 30
  • result: -120, -60, -30, 30


Fuzzy range from -120 to 30 make sentence activated


Then the sentence active value will be:

  • Full active 1.0: if Input Result from -60 to -30
  • Non active 0.0: if Input Result less than -120 or greater than 30
  • Float point active 0.x: if Input Result from -120 to -60 or -30 to 30

 

If in compare mode, the true range will be like this:

  • > 0


True range: input > 0 true


Then and a fuzzy value, such as 20, then turns out the fuzzy range:

  • > 0
  • fuzzy 20
  • => -20, 20


Fuzzy range: input greater than -20 make sentence activated


Then the sentence active value will be:

  • Full active 1.0: if Input Result greater than 20
  • Non active 0.0: if Input Result less than -20
  • Float point active 0.x: if Input Result from -20 to 20

Testing that Input Result with the fuzzy range, we can get the "sentence active" in this step

Step 3: Fuzzy Logic among Sentences Calculation (Node Active)

Among the different sentences, there are "active flags", "sentence priority", "'not' flags", "logic operators" and the ID of each sentence.

Using these logic tools and the "sentence active" of each sentence from previous step, we can calculate out the "node active"


Yellow bound are logic output


We can give a logic operator before the each sentence



&&: "and" operator, ||: "or" operator, xor: "exclusive or" operator


You can also using the "not flags", "sentence priority" modify the result, and the calculation rule will be conclusion in Parse Result, use this rule and sentence active from each one, we can finally get the node active



An example of more complicated situation, but usually we don't need that


Algorithm for prefix operator:

  • Add: the minimums active value
  • Or: the maximums active value
  • Exclusive Or (XOR): the absolute value of the different

After the calculation among these sentences, we will get the node active, in this step.

Step 4: Fuzzy Logic for Priority Ranking and Interfere to Node Active

By now, we have already known the node active, every node has its own node active, but if they are re-arranging by hierarchy, the node active will be interfered. The decision in higher hierarchy takes higher priority.



A real example of decision hierarchy


Direct hierarchy:


(1 – Node Active) will passed to the child, and multiple to the Node Active of child


For example, the node 1, node 2, node 3 active values are: 0.2, 1.0, and 0.5

  • the node1 active is 0.2, then the 0.8(1-0.2) will be passed to node2
  • the node2 active is 1.0 and it will yield to 0.8(1.0 * 0.8), and the 0.2(1.0 – 0.8) will be passed to node3
  • the node3 active is 0.1(0.5 * 0.2)

So the node active results of the 3 nodes are: 0.2, 0.8, and 0.1 after ranking priority.


Grouping hierarchy:



(1 – Max Active) will be passed to the child group, and multiply to all of the children decisions


For example the node active values from node1 to node 4 are 0.1, 0.4, 0.7 and 0.5

  • the max active value of node1 and 2 is 0.4, so 0.6(1.0 – 0.4) will be passed to group2 and multiple to node3 and node4
  • so the post-calculated active value of node3 is 0.42(0.7 * 0.6) and node4 is 0.3(0.5 * 0.6)


Grouping and Node Hierarchy Hybrid
You also can combine the direct and grouping method together, and the algorithm is the same



Hybrid hierarchy ranking priority

Step 5 & 6: Output Mechanism - Node Active, Default Decision and Normal Decision

Using each node active value, we can firstly get the output active of each node, and then solve out the decision results.

Just like the picture below, if the node active is 0.2 after sentences calculation. The "move FORWARD" and "rotate to RIGHT" sentences are active 0.2 for this specific node.

The decision results are

"rotate to RIGHT": 24 (120 * 0.2)

"move FORWARD" 4 (20 * 0.2).



Normal Decision determine output sentence based on node active


But please notice, this output active (like the 0.2 we just mentioned) is not the final sentence active for this type of decision, system need also calculate the node active from every node. And finally, system need solve out the ultimate correct active value of a type of sentence combine with several active values from every node and the default value of this sentence in the default decision.

Before continuing, we need now introduce a concept called default decision.

  • Default decision implicitly contains the default value of every sentence output. (even there is no default decision, these implicit values exist)
  • The default value means the value which output sentence will blend with, when this type of output sentence has not been fully activated by any of normal node.
  • One can explicitly specify one or more default values for some specific sentences and those default values will take place the implicit ones.

If we want to get the ultimate active value of specific sentence, we need combine with default decision node.



Default value will work when this sentence is not fully activated

 

 

 

 

 

Basefount Technology