mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-07 07:31:36 +01:00
finish better algo serverside
This commit is contained in:
13
server.py
13
server.py
@@ -145,6 +145,10 @@ def balanceTool():
|
|||||||
|
|
||||||
if flask.request.method == 'POST':
|
if flask.request.method == 'POST':
|
||||||
|
|
||||||
|
players = []
|
||||||
|
for k,v in flask.request.json.items():
|
||||||
|
players += [Player(k, v)]
|
||||||
|
|
||||||
permutations = itertools.permutations(players)
|
permutations = itertools.permutations(players)
|
||||||
|
|
||||||
best = 100
|
best = 100
|
||||||
@@ -154,16 +158,17 @@ def balanceTool():
|
|||||||
cur = 0
|
cur = 0
|
||||||
|
|
||||||
for i in range(len(option)):
|
for i in range(len(option)):
|
||||||
cur += option[i].prio[i%5]
|
cur += int(option[i].prio[i%5])
|
||||||
|
|
||||||
if cur < best:
|
if cur < best:
|
||||||
best = cur
|
best = cur
|
||||||
bestOption = option
|
bestOption = option
|
||||||
|
print(cur)
|
||||||
|
|
||||||
retDict = { "left" : {}, "right" : {} }
|
retDict = { "left" : {}, "right" : {} }
|
||||||
for i in range(len(positions)):
|
for i in range(5):
|
||||||
retDict["left"].update( { positions[i] : option[i].name })
|
retDict["left"].update( { positions[i] : bestOption[i].name })
|
||||||
retDict["right"].update({ positions[i] : option[i%5].name })
|
retDict["right"].update({ positions[i] : bestOption[i+5].name })
|
||||||
|
|
||||||
renderContent = flask.render_template("balance_response_partial.html", d=retDict,
|
renderContent = flask.render_template("balance_response_partial.html", d=retDict,
|
||||||
requests=flask.request.json,
|
requests=flask.request.json,
|
||||||
|
|||||||
Reference in New Issue
Block a user