Skip to content

Commit

Permalink
in analysis, <space> plays the best computer move - closes #2263
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Sep 20, 2016
1 parent 0c95832 commit 06fb9e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ui/analyse/src/ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ module.exports = function(opts) {
this.chessground.setAutoShapes(computeAutoShapes(this));
}.bind(this);

this.explorerMove = function(uci) {
var playUci = function(uci) {
var move = util.decomposeUci(uci);
if (uci[1] === '@') this.chessground.apiNewPiece({
color: this.chessground.data.movable.color,
Expand All @@ -457,9 +457,18 @@ module.exports = function(opts) {
move[1])
else if (!move[2]) sendMove(move[0], move[1])
else sendMove(move[0], move[1], util.sanToRole[move[2].toUpperCase()]);
}.bind(this);

this.explorerMove = function(uci) {
playUci(uci);
this.explorer.loading(true);
}.bind(this);

this.playBestMove = function() {
var uci = this.nextNodeBest() || (this.vm.node.ceval && this.vm.node.ceval.best);
if (uci) playUci(uci);
}.bind(this);

this.socketReceive = function(type, data) {
this.socket.receive(type, data);
}.bind(this);
Expand Down
2 changes: 2 additions & 0 deletions ui/analyse/src/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ module.exports = {
ctrl.explorer.toggle();
m.redraw();
}));
k.bind('space', preventing(ctrl.playBestMove));
if (ctrl.study) {
k.bind('c', preventing(function() {
$('.study_buttons a.comment').click();
Expand Down Expand Up @@ -127,6 +128,7 @@ module.exports = {
header('Analysis options'),
row([k('l')], 'Local computer analysis'),
row([k('a')], 'Computer arrows'),
row([k('space')], 'Play computer best move'),
row([k('e')], 'Opening/endgame explorer'),
row([k('f')], trans('flipBoard')),
row([k('/')], 'Focus chat'),
Expand Down

0 comments on commit 06fb9e1

Please sign in to comment.