Skip to content

Commit

Permalink
refactor: do not try to rebet if agent has never bet before
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantios committed Sep 26, 2024
1 parent 4ef3827 commit 4b95ef4
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ def __init__(self, **kwargs: Any) -> None:

def setup(self) -> None:
"""Setup the behaviour."""
random.seed(self.synchronized_data.most_voted_randomness)
self.should_rebet = random.random() <= self.params.rebet_chance # nosec
self.read_bets()
has_bet_in_the_past = any(bet.n_bets > 0 for bet in self.bets)
if has_bet_in_the_past:
random.seed(self.synchronized_data.most_voted_randomness)
self.should_rebet = random.random() <= self.params.rebet_chance # nosec
rebetting_status = "enabled" if self.should_rebet else "disabled"
self.context.logger.info(f"Rebetting {rebetting_status}.")

Expand Down Expand Up @@ -114,7 +117,6 @@ def _sample(self) -> Optional[int]:
def async_act(self) -> Generator:
"""Do the action."""
with self.context.benchmark_tool.measure(self.behaviour_id).local():
self.read_bets()
idx = self._sample()
self.store_bets()
if idx is None:
Expand Down

0 comments on commit 4b95ef4

Please sign in to comment.