es6-fuzz 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +55 -0
- package/docs/CHANGELOG.md +3 -3
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -58,6 +58,61 @@ var res = logic
|
|
|
58
58
|
|
|
59
59
|
* hot
|
|
60
60
|
|
|
61
|
+
|
|
62
|
+
## Usage with boon-js
|
|
63
|
+
|
|
64
|
+
In order to combine 2 fuzzy functions with boolean logic, there is a compat layer for boon-js which allows the sauge of 'boolean expression language'.
|
|
65
|
+
|
|
66
|
+
Example of a monster biting when its cold and you are close to it:
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Heat part:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
var logicHeat = new Logic();
|
|
73
|
+
const optimalTemperature = new Triangle(10, 20, 30);
|
|
74
|
+
const toColdTemperature = new Triangle(0, 10, 15);
|
|
75
|
+
const toHotTemperature = new Triangle(25, 40, 60);
|
|
76
|
+
|
|
77
|
+
logicHeat.init('cold', toColdTemperature)
|
|
78
|
+
logicHeat.or('optimal', optimalTemperature)
|
|
79
|
+
logicHeat.or('hot', toHotTemperature);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Distance Part
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
|
|
86
|
+
var logicDistance = new Logic();
|
|
87
|
+
const close = new Triangle(0, 10, 20);
|
|
88
|
+
const far = new Triangle(5, 50, 100);
|
|
89
|
+
|
|
90
|
+
logicDistance.init('close', close)
|
|
91
|
+
logicDistance.or('far', far)
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Now we marry the 2 and use boon js
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
const monsterBiteTest = getEvaluator(
|
|
99
|
+
'heat.cold AND distance.close',
|
|
100
|
+
);
|
|
101
|
+
const resHeat = logicHeat.defuzzify(2, 'heat');
|
|
102
|
+
const resClose = logicDistance.defuzzify(2, 'distance');
|
|
103
|
+
|
|
104
|
+
const jsBoonInput = { ...resHeat.boonJsInputs, ...resClose.boonJsInputs }
|
|
105
|
+
|
|
106
|
+
monsterBiteTest(jsBoonInput)
|
|
107
|
+
// returns true
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
61
116
|
## development
|
|
62
117
|
|
|
63
118
|
**Tests** use mocha and a plugin for traceur
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
2022-06-14
|
|
2
2
|
==========
|
|
3
3
|
|
|
4
|
+
* 4.0.1
|
|
5
|
+
* fix: update readme
|
|
6
|
+
* (churn): changelog
|
|
4
7
|
* 4.0.0
|
|
5
8
|
* feature: make the api work with boonJsInputs
|
|
6
9
|
* feature: add a test for outoput names only to consist of alphabet
|
|
@@ -147,6 +150,3 @@
|
|
|
147
150
|
* 2.5.7
|
|
148
151
|
* 2.5.6
|
|
149
152
|
* Added docs
|
|
150
|
-
* Fix output ght pages
|
|
151
|
-
* DOcs
|
|
152
|
-
* Ghpages
|
package/package.json
CHANGED