Skip to content

Commit

Permalink
Tie break top-scoring bandit actions by action name (#119)
Browse files Browse the repository at this point in the history
* tie break top-scoring actions by action name

* bump version number
  • Loading branch information
aarsilv authored Aug 8, 2024
1 parent ae6bfde commit 90dabbc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eppo/js-client-sdk-common",
"version": "4.0.1",
"version": "4.0.2",
"description": "Eppo SDK for client-side JavaScript applications (base for both web and react native)",
"main": "dist/index.js",
"files": [
Expand Down
7 changes: 6 additions & 1 deletion src/bandit-evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ export class BanditEvaluator {
let currTopScore: number | null = null;
let currTopAction: string | null = null;
actionScoreEntries.forEach(([actionKey, actionScore]) => {
if (currTopScore === null || actionScore > currTopScore) {
if (
currTopScore === null ||
currTopAction === null ||
actionScore > currTopScore ||
(actionScore === currTopScore && actionKey < currTopAction)
) {
currTopScore = actionScore;
currTopAction = actionKey;
}
Expand Down

0 comments on commit 90dabbc

Please sign in to comment.