修改抽签算法,降低随机性
This commit is contained in:
parent
46393fa443
commit
818008fc74
|
@ -178,8 +178,6 @@ def fetch_roll_result_list(interval: int = 0, limit: int = 3) -> Generator[str,
|
|||
row = cursor.fetchone()
|
||||
while row is not None:
|
||||
yield row[0]
|
||||
if interval != 0:
|
||||
return
|
||||
row = cursor.fetchone()
|
||||
finally:
|
||||
cursor.close()
|
||||
|
|
|
@ -74,7 +74,7 @@ def vote_reduce(summary: dict[str, float], limit: int = 2) -> tuple[dict[str, fl
|
|||
# 昨日中签项降低权重
|
||||
for i, last_result in enumerate(last_results):
|
||||
if last_result in summary:
|
||||
summary[last_result] = summary[last_result] * (9 - i) / 10
|
||||
summary[last_result] = summary[last_result] * (8 - i) / 10
|
||||
total_vote = sum(value for value in summary.values())
|
||||
return summary, total_vote, last_results
|
||||
|
||||
|
@ -163,6 +163,8 @@ def dinner():
|
|||
summary_keys = list(filter(lambda x: x in summary.keys(), map(lambda y: y['name'], all_choice)))
|
||||
if not result:
|
||||
predict_result = roll_logic(check=True)
|
||||
else:
|
||||
predict_result = None
|
||||
return render_template('dinner.html',
|
||||
all_choice=all_choice,
|
||||
menu=menu,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<p>每天8:00-17:30间开放匿名投票更新,17:30以后允许发起抽签,抽签结果确定后不可更改</p>
|
||||
<p>第一名与第二名得票数相差不超过10%时随机抽签,按其得票数决定中签概率,否则选择第一名</p>
|
||||
{% for last_result in last_results %}
|
||||
<p>今日{{ last_result }}最终得票数降低{{ 1 + loop.index0 }}0%</p>
|
||||
<p>今日{{ last_result }}最终得票数降低{{ 2 + loop.index0 }}0%</p>
|
||||
{% endfor %}
|
||||
<form id="inputForm" class="form-inline">
|
||||
<div class="form-group">
|
||||
|
|
Loading…
Reference in New Issue