me
/
LeekBots
Archived
1
0
Fork 0

Add selection-mode in fights

This commit is contained in:
sheychen 2018-02-10 18:17:19 +01:00
parent a11883eb26
commit 86c3b082f6
1 changed files with 38 additions and 15 deletions

View File

@ -299,12 +299,21 @@ class Pool:
if len(opponents) < 1:
leek.raiseError('Probably, no more fights')
if options['selection-mode'] == 'random':
opid = random.choice([
x['id'] for x in opponents
if force or not x['id'] in leeksids
])
else:
opid = None
if options['selection-mode'] == 'worst':
opscore = 20000000
else:
opscore = 0
for x in opponents:
if force or not x['id'] in leeksids:
score = x['level'] * x['talent']
if score < opscore:
if (options['selection-mode'] == 'worst' and score < opscore) or (not options['selection-mode'] == 'worst' and score > opscore):
opid = x['id']
opscore = score
@ -563,6 +572,7 @@ class Pool:
def teamFight(params, options):
try:
random.seed()
leek = Pool.get(Settings(options), Pool.parse(options))[0]
team = leek.farmer.data['team']['id']
for composition in leek.farmer.getTeam(team)['compositions']:
@ -575,10 +585,22 @@ class Pool:
if len(opponents) < 1:
leek.raiseError('Probably, no more team fights')
if options['selection-mode'] == 'random':
opid = random.choice(opponents)['id']
else:
opid = None
if options['selection-mode'] == 'worst':
optalent = 20000000
else:
optalent = 0
for x in opponents:
if x['talent'] < optalent:
if (
options['selection-mode'] == 'worst'
and optalent < x['talent']
) or (
not options['selection-mode'] == 'worst'
and optalent > x['talent']
):
opid = x['id']
optalent = x['talent']
@ -781,6 +803,7 @@ class Leek:
if __name__ == "__main__":
CommandTree()\
.addOption('pool', ['p', '-pool'], {'name': 'pool', 'optional': True, 'default': 'main'})\
.addOption('selection-mode', ['sm', '-selection-mode'], {'name': 'selection mode', 'optional': True, 'list': ['random', 'best', 'worst'], 'default': 'worst'})\
.addOption('sleep', ['s', '-sleep'], {'name': 'sleep time', 'optional': True, 'type': int, 'min': 0, 'default': 1})\
.addOption('path', ['-path'], {'name': 'config path', 'optional': True, 'default': '*/LeekBots.json'})\
.addCommand('farmers list', 'list all farmers', Farmers.list, [{'name': 'mode', 'optional': True, 'list': [None, 'infos', 'ais', 'stuff', 'leeks']}])\