cm-engine-runner 1.0.11 → 1.1.0
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
CHANGED
|
@@ -17,9 +17,24 @@
|
|
|
17
17
|
- Stockfish version: 14
|
|
18
18
|
- Latest js version, Multithreadded
|
|
19
19
|
|
|
20
|
+
## Stockfish Skill Levels
|
|
21
|
+
|
|
22
|
+
this.uciCmd('setoption name Skill Level value ' + (LEVELS[props.level][1]))
|
|
23
|
+
|
|
24
|
+
- Level 0 = 1100 ELO rating
|
|
25
|
+
- Level 1 = 1165 ELO rating
|
|
26
|
+
- Level 2 = 1230 ELO rating
|
|
27
|
+
|
|
28
|
+
As you can see the strength is increasing by 65 ELO points for each level, so that;
|
|
29
|
+
|
|
30
|
+
- Level 20 = 2570 ELO rating.
|
|
31
|
+
|
|
32
|
+
And depth to ELO: https://chess.stackexchange.com/questions/8123/stockfish-elo-vs-search-depth?rq=1
|
|
33
|
+
|
|
20
34
|
## References
|
|
21
35
|
|
|
22
36
|
- [UCI reference](http://page.mi.fu-berlin.de/block/uci.htm)
|
|
37
|
+
- [Official Stockfish](https://github.com/official-stockfish/Stockfish)
|
|
23
38
|
- [stockfish.js](https://github.com/nmrugg/stockfish.js/)
|
|
24
39
|
- https://github.com/mcostalba/Stockfish
|
|
25
40
|
- https://github.com/niklasf/stockfish.js (stockfish-v10-niklasf.js)
|
package/package.json
CHANGED
|
@@ -32,14 +32,14 @@ export class PolyglotRunner extends EngineRunner {
|
|
|
32
32
|
if(this.props.debug) {
|
|
33
33
|
console.log(fen, "moves found in opening book", moves)
|
|
34
34
|
}
|
|
35
|
-
// handle
|
|
35
|
+
// handle probability
|
|
36
36
|
const propabilityMatrix = []
|
|
37
37
|
for (const move of moves) {
|
|
38
38
|
for (let i = 0; i < (move.probability * 10); i++) {
|
|
39
39
|
propabilityMatrix.push(move)
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
//
|
|
42
|
+
// probability weighted random
|
|
43
43
|
const luckyIndex = Math.floor(Math.random() * propabilityMatrix.length)
|
|
44
44
|
resolve(propabilityMatrix[luckyIndex])
|
|
45
45
|
})
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Author and copyright: Stefan Haack (https://shaack.com)
|
|
3
|
-
* Repository: https://github.com/shaack/cm-engine-runner
|
|
3
|
+
* Repository: https://github.com/shaack/cm-chess-engine-runner
|
|
4
4
|
* License: MIT, see file 'LICENSE'
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {ENGINE_STATE, EngineRunner} from "./EngineRunner.js"
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
// [depth, Skill Level]
|
|
10
|
+
export const LEVELS = {
|
|
11
|
+
1: [3, 0],
|
|
12
|
+
2: [3, 1],
|
|
13
|
+
3: [4, 2],
|
|
14
|
+
4: [5, 3],
|
|
15
|
+
5: [5, 4],
|
|
16
|
+
6: [6, 5],
|
|
17
|
+
7: [7, 6],
|
|
18
|
+
8: [8, 7],
|
|
19
|
+
9: [9, 8],
|
|
20
|
+
10: [10, 10],
|
|
21
|
+
11: [11, 11],
|
|
22
|
+
12: [12, 12],
|
|
23
|
+
13: [13, 13],
|
|
24
|
+
14: [14, 14],
|
|
25
|
+
15: [15, 15],
|
|
26
|
+
16: [16, 16],
|
|
27
|
+
17: [17, 17],
|
|
28
|
+
18: [18, 18],
|
|
29
|
+
19: [19, 19],
|
|
30
|
+
20: [20, 20]
|
|
20
31
|
}
|
|
21
32
|
|
|
22
33
|
export class StockfishRunner extends EngineRunner {
|
|
@@ -99,8 +110,9 @@ export class StockfishRunner extends EngineRunner {
|
|
|
99
110
|
})
|
|
100
111
|
const calculationPromise = new Promise ((resolve) => {
|
|
101
112
|
setTimeout(() => {
|
|
113
|
+
this.uciCmd('setoption name Skill Level value ' + (LEVELS[props.level][1]))
|
|
102
114
|
this.uciCmd('position fen ' + fen)
|
|
103
|
-
this.uciCmd('go depth ' + (
|
|
115
|
+
this.uciCmd('go depth ' + (LEVELS[props.level][0]))
|
|
104
116
|
this.moveResponse = (move) => {
|
|
105
117
|
resolve(move)
|
|
106
118
|
}
|
|
@@ -121,4 +133,4 @@ export class StockfishRunner extends EngineRunner {
|
|
|
121
133
|
this.engineWorker.postMessage(cmd)
|
|
122
134
|
}
|
|
123
135
|
|
|
124
|
-
}
|
|
136
|
+
}
|