Skip to content

Commit

Permalink
Update server decision display to use the AI position outputs and be …
Browse files Browse the repository at this point in the history
…clearer about why the game ended
  • Loading branch information
anoek committed May 25, 2024
1 parent 8828c46 commit 77bc1f3
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"express": "^4.19.2",
"express-http-proxy": "^2.0.0",
"fork-ts-checker-webpack-plugin": "^9.0.0",
"goban": "=0.7.44",
"goban": "=0.7.46",
"gulp": "^5.0.0",
"gulp-clean-css": "^4.3.0",
"gulp-eslint-new": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export function getOutcomeTranslation(outcome: string) {
}

if (outcome.indexOf("Server Decision") === 0) {
return pgettext("Game outcome", "Server Decision") + " " + outcome.substring(16);
return pgettext("Game outcome", "Server Decision");
}

if (/[0-9.]+/.test(outcome)) {
Expand Down
13 changes: 11 additions & 2 deletions src/views/Game/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1251,8 +1251,17 @@ export function Game(): JSX.Element | null {
engine.outcome !== "Cancellation" &&
goban.current!.mode === "play"
) {
const s = engine.computeScore(false);
goban.current!.showScores(s);
if (
engine.phase === "finished" &&
engine.outcome.indexOf("Server Decision") === 0
) {
if (engine.stalling_score_estimate) {
goban.current!.showStallingScoreEstimate(engine.stalling_score_estimate);
}
} else {
const s = engine.computeScore(false);
goban.current!.showScores(s);
}
}
};

Expand Down
8 changes: 8 additions & 0 deletions src/views/Game/PlayControls.styl
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,12 @@
bottom: 0.5em;
*/
}

.stalling-score-estimate {
margin: 0.5rem;
font-size: 1.0rem;
font-style: italic;
text-wrap: balance;
text-wrap-mode: balance;
}
}
62 changes: 44 additions & 18 deletions src/views/Game/PlayControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ export function PlayControls({
return false;
};

const sse = engine.stalling_score_estimate;

return (
<div className="PlayControls">
<div className="game-action-buttons">
Expand Down Expand Up @@ -293,24 +295,48 @@ export function PlayControls({
{(mode === "score estimation" || null) && renderEstimateScore()}

{((mode === "play" && phase === "finished") || null) && (
<span style={{ textDecoration: annulled ? "line-through" : "none" }}>
{winner
? interpolate(
pgettext("Game winner", "{{color}} wins by {{outcome}}"),
{
// When is winner an id?
color:
(winner as any) === engine.players.black.id ||
winner === "black"
? _("Black")
: _("White"),
outcome: getOutcomeTranslation(engine.outcome),
},
)
: interpolate(pgettext("Game winner", "Tie by {{outcome}}"), {
outcome: pgettext("Game outcome", engine.outcome),
})}
</span>
<>
<span style={{ textDecoration: annulled ? "line-through" : "none" }}>
{winner
? interpolate(
pgettext("Game winner", "{{color}} wins by {{outcome}}"),
{
// When is winner an id?
color:
(winner as any) === engine.players.black.id ||
winner === "black"
? _("Black")
: _("White"),
outcome: getOutcomeTranslation(engine.outcome),
},
)
: interpolate(pgettext("Game winner", "Tie by {{outcome}}"), {
outcome: pgettext("Game outcome", engine.outcome),
})}
</span>
{engine.stalling_score_estimate && sse && (
<div className="stalling-score-estimate">
<span>
{interpolate(
_(
"The AI has concluded {{color}} will win with {{certainty}}% certainty. This result has been accepted by one or more players",
),
{
color:
sse.predicted_winner === "black"
? _("Black")
: _("White"),
certainty: (
(sse.predicted_winner === "black"
? sse.win_rate
: 1.0 - sse.win_rate) * 100.0
).toFixed(2),
},
)}
</span>
</div>
)}
</>
)}
</div>
<div className="annulled-indicator">
Expand Down
3 changes: 2 additions & 1 deletion src/views/Game/PlayerCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ export function PlayerCard({
goban.mode !== "analyze" &&
engine.outcome !== "Timeout" &&
engine.outcome !== "Resignation" &&
engine.outcome !== "Cancellation";
engine.outcome !== "Cancellation" &&
!engine.outcome.startsWith("Server Decision");

return (
<div className={`${color} ${highlight_their_turn} player-container`}>
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5939,10 +5939,10 @@ glogg@^2.2.0:
dependencies:
sparkles "^2.1.0"

goban@=0.7.44:
version "0.7.44"
resolved "https://registry.yarnpkg.com/goban/-/goban-0.7.44.tgz#56b3801d6a14a4ffd2fde0009d17d338d7692abd"
integrity sha512-3bx5UcCftXGM814VKwUTWN1AaowfgAkYFg2CExtwxWwGSP6dG6bcDhnQ+kC/PfMrz3m+DRKae5qNTbNyTP5UAg==
goban@=0.7.45:
version "0.7.45"
resolved "https://registry.yarnpkg.com/goban/-/goban-0.7.45.tgz#d63f025fded096331594aa9e264d010e3888814f"
integrity sha512-f53uItDIsl8v0p7KdyYBXXo9ts6p8FbBE++hYIwxNuKCGtzPxQGTDc+CGHmgOVFqzJwgsopGF3JoXn9Co5SpvQ==
dependencies:
eventemitter3 "^5.0.0"

Expand Down

0 comments on commit 77bc1f3

Please sign in to comment.