Lower base to 1.5

This commit is contained in:
Robert Miles 2023-04-06 20:08:24 +00:00
parent 37568d13f0
commit 9469b3263d
1 changed files with 11 additions and 5 deletions

View File

@ -1,4 +1,6 @@
import plugin, tasks, time, random, math
from statistics import mean as average
from statistics import median
from bot import IRCLine
BOT=None
@ -42,14 +44,15 @@ def deactivate_bun(channel):
bungame_data["bun_time"]=time.time()
bungame_data["bun_active"]=False
# Base is such that b^(1 hour in seconds) = 3.
# Base is such that b^(1 hour in seconds) = 1.5.
# 2020-11-16 - A 2 hour bun awards 6,322,008.86 points, base is lowered from b^(1 hour in seconds) = 1000.
# 2020-11-17 - A 4:46:01.66 bun awards 3 billion and a 6:08:09.27 awards over a trillion. Base is lowered from 100.
# 2020-12-03 - After some fun with really long buns, I decide enough is enough and lower the base even more. Base lowered from 10.
# 2020-12-14 - Late Monday night I decide to lower the base slightly, from 5.
# 2021-06-04 - I decide to lower the base from 3, after almost 6 months of just leaving it as-is.
# 2023-04-06 - The bot overflows when we try to get the bun score. Lowered from 2.
# This is probably too much and too easily abused but hell we'll give it a shot.
BASE = 2**(1/(60*60))
BASE = 1.5**(1/(60*60))
def bun_score(time_delta):
"""Generates the score for a bun."""
return BASE**time_delta
@ -124,8 +127,6 @@ def on_peek(event):
score_r=round(score,2)
respond(event,f"If you were to befriend the bun right now, it would have waited {delta_r:,} second(s), and would therefore be worth {score_r:.2e} point(s).")
average = lambda l: sum(l)/len(l)
def on_stats(event):
if not event.target.startswith("#"): return
if "account" not in event.tags:
@ -143,7 +144,7 @@ def on_stats(event):
def on_top10(event):
mode = "score"
if event.parts and event.parts[0] in "score count time".split():
if event.parts and event.parts[0] in "score count time median".split():
mode = event.parts[0]
accounts = list(bungame_data["buns"].keys())
if mode == "score":
@ -155,6 +156,9 @@ def on_top10(event):
elif mode == "time":
accounts.sort(key=lambda k: average(bungame_data["buns"].get(k,[0])),reverse=True)
accounts = [(bungame_data["association"].get(account,account),average(bungame_data["buns"].get(account,[0]))) for account in accounts[:10]]
elif mode == "median":
accounts.sort(key=lambda k: median(bungame_data["buns"].get(k,[0])),reverse=True)
accounts = [(bungame_data["association"].get(account,account),median(bungame_data["buns"].get(account,[0]))) for account in accounts[:10]]
out = f"Top 10 in {mode}: "
for account in accounts:
if mode == "count":
@ -175,6 +179,8 @@ def admin_merge(event):
except:
respond(event,"Syntax: admin merge <target> <from>")
return
if target not in bungame_data["buns"]: bungame_data["buns"][target]=[]
print(target,from_,target in bungame_data["buns"])
bungame_data["buns"][target].extend(bungame_data["buns"][from_])
bungame_data.save()
del bungame_data["buns"][from_]