Skip to content

Commit

Permalink
allow values to be zero
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsung committed Sep 27, 2021
1 parent 64c8e75 commit a2880da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/Goban.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export default class Goban extends Component {
for (const v in board.childrenInfo) {
const [x, y] = v.split(',').map(x => +x)
const {visits, winrate, scoreLead} = board.childrenInfo[v]
if (visits && winrate) {
if (isFinite(visits) && isFinite(winrate)) {
variations.push({vertex: [x, y], visits, winrate, scoreLead})
}
}
Expand Down
18 changes: 12 additions & 6 deletions src/modules/gametree.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,18 @@ export function getBoard(tree, id) {
type = 'good'
}

const visits = node.data.VISITS || null
const winrate =
(node.data.WINRATE && (0.5 + sign * (node.data.WINRATE - 0.5)) * 100) ||
null
const scoreLead =
(node.data.SCORELEAD && node.data.SCORELEAD * sign) || null
let visits = null
let winrate = null
let scoreLead = null
if (isFinite(node.data.VISITS)) {
visits = +node.data.VISITS
}
if (isFinite(node.data.WINRATE)) {
winrate = (0.5 + sign * (node.data.WINRATE - 0.5)) * 100
}
if (isFinite(node.data.SCORELEAD)) {
scoreLead = node.data.SCORELEAD * sign
}

list[v] = {sign, type, visits, winrate, scoreLead}
}
Expand Down

0 comments on commit a2880da

Please sign in to comment.