DedeProGames commited on
Commit
42fe076
·
verified ·
1 Parent(s): 978c431

Season 2: start a fresh leaderboard

Browse files
Files changed (1) hide show
  1. arena.py +8 -2
arena.py CHANGED
@@ -16,7 +16,9 @@ from tetris import TetrisGame
16
  MAX_PIECES = int(os.environ.get("MAX_PIECES", 500))
17
  K_FACTOR = 32
18
  START_ELO = 1000.0
19
- APP_VERSION = "1.0"
 
 
20
 
21
 
22
  def choose(game: TetrisGame, player, protocol: str, seed: int):
@@ -78,12 +80,15 @@ class ResultsStore:
78
  return bool(self.token)
79
 
80
  def _empty(self):
81
- return {"version": 1, "updated": None, "protocols": {"guided": {}, "blind": {}}}
82
 
83
  def _load(self):
84
  try:
85
  path = hf_hub_download(self.repo_id, "leaderboard.json", repo_type="dataset", token=self.token, force_download=True)
86
  data = json.load(open(path))
 
 
 
87
  data.setdefault("protocols", {}).setdefault("guided", {})
88
  data["protocols"].setdefault("blind", {})
89
  self.load_error = None
@@ -115,6 +120,7 @@ class ResultsStore:
115
  "seed": seed,
116
  "max_pieces": MAX_PIECES,
117
  "app_version": APP_VERSION,
 
118
  "players": [],
119
  }
120
  for p, g, r, d, rank in zip(players, games, ratings, deltas, ranks):
 
16
  MAX_PIECES = int(os.environ.get("MAX_PIECES", 500))
17
  K_FACTOR = 32
18
  START_ELO = 1000.0
19
+ APP_VERSION = "1.1"
20
+ # Bump to start a fresh leaderboard: data saved under another season is ignored.
21
+ SEASON = 2
22
 
23
 
24
  def choose(game: TetrisGame, player, protocol: str, seed: int):
 
80
  return bool(self.token)
81
 
82
  def _empty(self):
83
+ return {"version": 1, "season": SEASON, "updated": None, "protocols": {"guided": {}, "blind": {}}}
84
 
85
  def _load(self):
86
  try:
87
  path = hf_hub_download(self.repo_id, "leaderboard.json", repo_type="dataset", token=self.token, force_download=True)
88
  data = json.load(open(path))
89
+ if data.get("season") != SEASON:
90
+ self.load_error = None
91
+ return self._empty() # previous season: start clean
92
  data.setdefault("protocols", {}).setdefault("guided", {})
93
  data["protocols"].setdefault("blind", {})
94
  self.load_error = None
 
120
  "seed": seed,
121
  "max_pieces": MAX_PIECES,
122
  "app_version": APP_VERSION,
123
+ "season": SEASON,
124
  "players": [],
125
  }
126
  for p, g, r, d, rank in zip(players, games, ratings, deltas, ranks):