render movetimes & advantage charts with precise blurs
parent
f1026528ca
commit
a849e49225
|
@ -5,7 +5,7 @@
|
|||
@if(game.playerBlurPercent(p.color) > 30) {
|
||||
<br />
|
||||
<span class="mod blurs">
|
||||
@playerLink(p, cssClass = s"is color-icon ${p.color.name}".some, withOnline = false, mod = true) @p.blurs/@game.playerMoves(p.color) blurs
|
||||
@playerLink(p, cssClass = s"is color-icon ${p.color.name}".some, withOnline = false, mod = true) @p.blurs.nb/@game.playerMoves(p.color) blurs
|
||||
<strong>@game.playerBlurPercent(p.color)%</strong>
|
||||
</span>
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ object Blurs {
|
|||
|
||||
def asInt = (bits <= Int.MaxValue) option bits.toInt
|
||||
|
||||
override def toString = java.lang.Long toBinaryString bits
|
||||
override def toString = java.lang.Long.toBinaryString(bits).reverse
|
||||
}
|
||||
|
||||
implicit val blursZero = Zero.instance[Blurs](Bits(0l))
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
function toBlurArray(player) {
|
||||
return player.blurs && player.blurs.bits ? player.blurs.bits.split('') : [];
|
||||
}
|
||||
lichess.advantageChart = function(data) {
|
||||
lichess.loadScript('/assets/javascripts/chart/common.js').done(function() {
|
||||
lichess.loadScript('/assets/javascripts/chart/division.js').done(function() {
|
||||
|
@ -9,12 +12,18 @@ lichess.advantageChart = function(data) {
|
|||
|
||||
var $elem = $('#adv_chart');
|
||||
|
||||
var blurs = [ toBlurArray(data.player), toBlurArray(data.opponent) ];
|
||||
if (data.player.color === 'white') blurs.reverse();
|
||||
|
||||
var makeSerieData = function(d) {
|
||||
return d.treeParts.slice(1).map(function(node) {
|
||||
return d.treeParts.slice(1).map(function(node, i) {
|
||||
|
||||
var color = node.ply & 1;
|
||||
|
||||
if (node.eval && node.eval.mate) {
|
||||
var cp = node.eval.mate > 0 ? Infinity : -Infinity;
|
||||
} else if (node.san.indexOf('#') > 0) {
|
||||
var cp = node.ply % 2 === 1 ? Infinity : -Infinity;
|
||||
var cp = color === 1 ? Infinity : -Infinity;
|
||||
if (d.game.variant.key === 'antichess') cp = -cp;
|
||||
} else if (node.eval && typeof node.eval.cp !== 'undefined') {
|
||||
var cp = node.eval.cp;
|
||||
|
@ -23,11 +32,22 @@ lichess.advantageChart = function(data) {
|
|||
};
|
||||
|
||||
var turn = Math.floor((node.ply - 1) / 2) + 1;
|
||||
var dots = node.ply % 2 === 1 ? '.' : '...';
|
||||
return {
|
||||
var dots = color === 1 ? '.' : '...';
|
||||
var point = {
|
||||
name: turn + dots + ' ' + node.san,
|
||||
y: 2 / (1 + Math.exp(-0.004 * cp)) - 1
|
||||
};
|
||||
if (blurs[color].shift() === '1') {
|
||||
point.marker = {
|
||||
symbol: 'square',
|
||||
radius: 3,
|
||||
lineWidth: '1px',
|
||||
lineColor: '#d85000',
|
||||
fillColor: color ? '#fff' : '#333'
|
||||
};
|
||||
point.name += ' [blur]';
|
||||
}
|
||||
return point;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
function toBlurArray(player) {
|
||||
return player.blurs && player.blurs.bits ? player.blurs.bits.split('') : [];
|
||||
}
|
||||
lichess.movetimeChart = function(data) {
|
||||
lichess.loadScript('/assets/javascripts/chart/common.js').done(function() {
|
||||
lichess.loadScript('/assets/javascripts/chart/division.js').done(function() {
|
||||
|
@ -13,12 +16,15 @@ lichess.movetimeChart = function(data) {
|
|||
|
||||
var tree = data.treeParts;
|
||||
var moveCentis = data.game.moveCentis ||
|
||||
data.game.moveTimes.map(function(i) { return i * 10; });
|
||||
data.game.moveTimes.map(function(i) { return i * 10; });
|
||||
var ply = 0;
|
||||
var max = 0;
|
||||
|
||||
var logC = Math.pow(Math.log(3), 2);
|
||||
|
||||
var blurs = [ toBlurArray(data.player), toBlurArray(data.opponent) ];
|
||||
if (data.player.color === 'white') blurs.reverse();
|
||||
|
||||
moveCentis.forEach(function(time, i) {
|
||||
var node = tree[i + 1];
|
||||
ply = node ? node.ply : ply + 1;
|
||||
|
@ -30,11 +36,24 @@ lichess.movetimeChart = function(data) {
|
|||
var y = Math.pow(Math.log(.005 * Math.min(time, 12e4) + 3), 2) - logC;
|
||||
max = Math.max(y, max);
|
||||
|
||||
series[color ? 'white' : 'black'].push({
|
||||
var point = {
|
||||
name: turn + (color ? '. ' : '... ') + san,
|
||||
x: i,
|
||||
y: color ? y : -y
|
||||
});
|
||||
};
|
||||
|
||||
if (blurs[color].shift() === '1') {
|
||||
point.marker = {
|
||||
symbol: 'square',
|
||||
radius: 3,
|
||||
lineWidth: '1px',
|
||||
lineColor: '#3893E8',
|
||||
fillColor: color ? '#fff' : '#333'
|
||||
};
|
||||
point.name += ' [blur]';
|
||||
}
|
||||
|
||||
series[color ? 'white' : 'black'].push(point);
|
||||
});
|
||||
|
||||
var disabled = {
|
||||
|
|
Loading…
Reference in New Issue