Skip to content

Commit

Permalink
Upgrade to Sunsetter8 (fixes #2199)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Sep 20, 2016
1 parent 06fb9e1 commit 76af761
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
7 changes: 4 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
[submodule "public/vendor/stockfish.js"]
path = public/vendor/stockfish.js
url = https://github.com/niklasf/stockfish.js
[submodule "public/vendor/Sunsetter"]
path = public/vendor/Sunsetter
url = https://github.com/niklasf/Sunsetter.git
[submodule "public/vendor/flatpickr"]
path = public/vendor/flatpickr
url = https://github.com/chmln/flatpickr
Expand All @@ -43,3 +40,7 @@
[submodule "public/visualizer"]
path = public/visualizer
url = https://github.com/ornicar/chess_game_visualizer
[submodule "public/vendor/Sunsetter8"]
path = public/vendor/Sunsetter8
url = https://github.com/niklasf/Sunsetter8
branch = js
1 change: 0 additions & 1 deletion public/vendor/Sunsetter
Submodule Sunsetter deleted from db9688
1 change: 1 addition & 0 deletions public/vendor/Sunsetter8
Submodule Sunsetter8 added at 374424
15 changes: 5 additions & 10 deletions ui/analyse/src/ceval/sunsetterWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,14 @@ module.exports = function(opts, name) {

// transform mate scores
if (Math.abs(cp) > 20000) {
mate = Math.floor((30000 - Math.abs(cp)) / 10);
mate = Math.floor((30000 - Math.abs(cp)) / 10) + 1;
// approx depth for searches that end early with mate
depth = Math.max(depth || 0, mate * 2 - 1);
// correct sign and add sunsetter played moves
mate = Math.sign(cp) * (mate + aiMoves)
mate = Math.sign(cp) * (mate + aiMoves);
cp = undefined;
}

if (mate) {
stopping = true
send('force');
send('tellics stopped');
}

work.emit({
work: work,
eval: {
Expand All @@ -89,7 +83,7 @@ module.exports = function(opts, name) {

var reboot = function() {
if (instance) instance.terminate();
instance = new Worker('/assets/vendor/Sunsetter/sunsetter.js');
instance = new Worker('/assets/vendor/Sunsetter8/sunsetter.js');
busy = false;
stopping = false;
aiMoves = 0;
Expand All @@ -102,8 +96,9 @@ module.exports = function(opts, name) {
start: function(work) {
if (busy) reboot();
busy = true;
send('variant ' + opts.variant.key);
send('reset ' + opts.variant.key);
send('setboard ' + work.initialFen);
send('easy');
send('force');
for (var i = 0; i < work.moves.length; i++) {
send(work.moves[i]);
Expand Down

2 comments on commit 76af761

@ornicar
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's on prod now

@niklasf
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.