mirror of
https://github.com/FAUSheppy/skillbird
synced 2025-12-11 00:38:31 +01:00
implement ffa parsing
This commit is contained in:
@@ -49,6 +49,38 @@ def rate_teams_simple(winner_team, loser_team, weights=None):
|
|||||||
clean_rounds += 1
|
clean_rounds += 1
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def rate_ffa(players):
|
||||||
|
'''Takes a list of players in reverse finishing order (meaning best first)
|
||||||
|
perform a truskill evaluation and write it to database'''
|
||||||
|
|
||||||
|
# one player doesnt make sense #
|
||||||
|
if len(players) <= 1:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# create list of dicts for trueskill-library #
|
||||||
|
playerRatingTupelDicts = []
|
||||||
|
for p in players:
|
||||||
|
playerRatingTupelDicts += [{p:p.rating}]
|
||||||
|
|
||||||
|
# generate ranks
|
||||||
|
ranks = [ i for i in range(0, len(playerRatingTupelDicts))]
|
||||||
|
|
||||||
|
# rate and safe to database #
|
||||||
|
rated = env.rate(playerRatingTupelDicts)
|
||||||
|
|
||||||
|
# create sync dict #
|
||||||
|
# first player is handled seperately #
|
||||||
|
allPlayer = dict()
|
||||||
|
for playerRatingDict in rated[1:]:
|
||||||
|
allPlayer.update(playerRatingDict)
|
||||||
|
|
||||||
|
# only first player gets win #
|
||||||
|
StorrageBackend.sync_to_database(rated[0], True)
|
||||||
|
StorrageBackend.sync_to_database(allPlayer, False)
|
||||||
|
|
||||||
|
for p in allPlayer.keys():
|
||||||
|
print(p)
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
################### LOCK/GETTER ####################
|
################### LOCK/GETTER ####################
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import NetworkListener
|
|||||||
import httpAPI
|
import httpAPI
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
|
import backends.genericFFA as ffaParser
|
||||||
|
import insurgencyParsing as iparser
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Insurgency rating python backend server')
|
parser = argparse.ArgumentParser(description='Insurgency rating python backend server')
|
||||||
parser.add_argument('files', metavar='FILE', type=str, nargs='+',\
|
parser.add_argument('files', metavar='FILE', type=str, nargs='+',\
|
||||||
help='one or more logfiles to parse')
|
help='one or more logfiles to parse')
|
||||||
@@ -24,16 +27,26 @@ parser.add_argument('--one-thread', dest='oneThread', action='store_const',\
|
|||||||
help="run everything in main thread (implies no-follow)")
|
help="run everything in main thread (implies no-follow)")
|
||||||
parser.add_argument('--cache-file', dest='cacheFile',\
|
parser.add_argument('--cache-file', dest='cacheFile',\
|
||||||
help="A cache file which makes restarting the system fast")
|
help="A cache file which makes restarting the system fast")
|
||||||
|
parser.add_argument('--ffa', action='store_const', default=False, const=True, \
|
||||||
|
help="Use the free-for-all parser")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.cacheFile:
|
if args.cacheFile:
|
||||||
open(args.cacheFile, "a").close()
|
open(args.cacheFile, "a").close()
|
||||||
|
|
||||||
|
if args.ffa:
|
||||||
|
parser = ffaParser
|
||||||
|
else:
|
||||||
|
parser = iparser
|
||||||
|
|
||||||
FileReader.readfiles( args.files ,\
|
FileReader.readfiles( args.files ,\
|
||||||
start_at_end=args.start_at_end,\
|
start_at_end=args.start_at_end,\
|
||||||
nofollow=args.nofollow, \
|
nofollow=args.nofollow, \
|
||||||
oneThread=args.oneThread, \
|
oneThread=args.oneThread, \
|
||||||
cacheFile=args.cacheFile)
|
cacheFile=args.cacheFile, \
|
||||||
|
parsingBackend=parser)
|
||||||
|
|
||||||
if not args.parse_only:
|
if not args.parse_only:
|
||||||
print("Starting network-listener(s)")
|
print("Starting network-listener(s)")
|
||||||
Thread(target=httpAPI.app.run).start()
|
Thread(target=httpAPI.app.run).start()
|
||||||
|
|||||||
Reference in New Issue
Block a user