Skip to content

Commit

Permalink
Combine evaluation and pv comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gruppler committed Aug 29, 2024
1 parent 88679be commit 93cf3d3
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions src/components/drawers/BotSuggestions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,6 @@ export default {
);
},
plyHasPVComment(ply, pv = null) {
return (
ply.id in this.game.comments.notes &&
this.game.comments.notes[ply.id].some((comment) =>
pv === null ? comment.pv : comment.message === pv
)
);
},
getEvalComments(ply, settingsHash) {
let comments = [];
let positionBefore = this.positions[ply.tpsBefore];
Expand Down Expand Up @@ -492,7 +483,22 @@ export default {
? evaluationAfter
: positionAfter[settingsHash][0].evaluation)
) / 1e4;
comments.push(`${evaluationAfter >= 0 ? "+" : ""}${evaluationAfter}`);
let evaluationComment = `${
evaluationAfter >= 0 ? "+" : ""
}${evaluationAfter}`;
if (positionBefore && settingsHash in positionBefore) {
let position = positionBefore[settingsHash][0];
if (position && position.ply) {
let pv = [position.ply, ...position.followingPlies]
.slice(0, 3)
.map((ply) => ply.ptn);
evaluationComment += `, pv ${pv.join(" ")}`;
}
}
comments.push(evaluationComment);
if (
evaluationBefore !== null ||
(positionBefore && settingsHash in positionBefore)
Expand Down Expand Up @@ -524,20 +530,6 @@ export default {
return comments;
},
getPVComment(ply, settingsHash) {
let positionBefore = this.positions[ply.tpsBefore];
if (positionBefore && settingsHash in positionBefore) {
let position = positionBefore[settingsHash][0];
if (position && position.ply) {
let pv = [position.ply, ...position.followingPlies]
.slice(0, 3)
.map((ply) => ply.ptn);
return `pv ${pv.join(" ")}`;
}
}
return null;
},
goToAnalysisPly() {
if (this.analyzingPly) {
this.$store.dispatch("game/GO_TO_PLY", {
Expand Down Expand Up @@ -600,10 +592,6 @@ export default {
if (evaluations.length) {
notes.push(...evaluations);
}
let pv = this.getPVComment(ply, settingsHash);
if (pv !== null && !this.plyHasPVComment(ply, pv)) {
notes.push(pv);
}
messages[ply.id] = notes;
});
this.$store.dispatch("game/ADD_NOTES", messages);
Expand Down

0 comments on commit 93cf3d3

Please sign in to comment.