|
| 1 | +import os |
1 | 2 | import sqlite3 |
2 | 3 | import sys |
3 | 4 | import threading |
@@ -611,8 +612,19 @@ def __init__(self, profile: "Profile"): |
611 | 612 | self._pickup_items: dict[int, PickupItem] = self._get_pickup_items() |
612 | 613 | self._base_data: dict[str, str | None] = self._get_base_data() |
613 | 614 |
|
614 | | - self._encounter_timestamps: deque[float] = deque(maxlen=100) |
615 | | - self._encounter_frames: deque[int] = deque(maxlen=100) |
| 615 | + # Normally, the encounter rate is calculated based on the previous 100 encounters. Which |
| 616 | + # is accurate enough to get a rough idea of how fast things are going, and it means that |
| 617 | + # a long break in between encounters (due to changing modes, playing manually etc.) will |
| 618 | + # be flushed out reasonably soon. |
| 619 | + # But when trying to measure a more accurate encounters/hr for a given route, we need a |
| 620 | + # larger sample size because the encounter rate can fluctuate quite a bit in some modes. |
| 621 | + # |
| 622 | + # So rather than constantly having to edit this file, this allows setting the environment |
| 623 | + # variable `POKEBOT_ENCOUNTER_BENCHMARK` to anything but an empty string in order to |
| 624 | + # increase the sample size to 1,000. |
| 625 | + encounter_buffer_size = 1000 if os.getenv("POKEBOT_ENCOUNTER_BENCHMARK", "") != "" else 100 |
| 626 | + self._encounter_timestamps: deque[float] = deque(maxlen=encounter_buffer_size) |
| 627 | + self._encounter_frames: deque[int] = deque(maxlen=encounter_buffer_size) |
616 | 628 |
|
617 | 629 | def set_data(self, key: str, value: str | None): |
618 | 630 | self._execute_write("REPLACE INTO base_data (data_key, value) VALUES (?, ?)", (key, value)) |
|
0 commit comments