Revamp how gamemode votes work
- Majority vote will still select that mode unconditionally - When there is no majority vote, the game mode is decided in a two-step process: 1. The bot will first try to select a game mode among those voted vs a random gamemode (for the purpose of this, all players who did not vote are considered to have voted for a random gamemode). For example, in an 8 player game if there are 2 votes for foolish, 2 votes for aleatoire, and 1 vote for default, one of `{foolish, foolish, aleatoire, aleatoire, default, random gamemode, random gamemode, random gamemode}` will be chosen (25% foolish, 25% alea, 12.5% default, 37.5% random gamemode) 2. If random gamemode is selected, a random mode is selected according to the base likelihoods. Votes do not modify this anymore Votes which are for majority-only modes or modes with incorrect player counts are not counted (and treated as votes for a random gamemode instead)
This commit is contained in:
parent
38505ba9a9
commit
5f7e4e4d05
@ -4622,10 +4622,23 @@ def start(cli, nick, chan, forced = False, restart = ""):
|
||||
cgamemode(random.choice(voted))
|
||||
else:
|
||||
possiblegamemodes = []
|
||||
for gamemode in var.GAME_MODES.keys() - var.DISABLED_GAMEMODES:
|
||||
if len(villagers) >= var.GAME_MODES[gamemode][1] and len(villagers) <= var.GAME_MODES[gamemode][2] and var.GAME_MODES[gamemode][3] > 0:
|
||||
possiblegamemodes += [gamemode]*(var.GAME_MODES[gamemode][3]+votes.get(gamemode, 0)*15)
|
||||
cgamemode(random.choice(possiblegamemodes))
|
||||
numvotes = 0
|
||||
for gamemode, num in votes.items():
|
||||
if len(villagers) < var.GAME_MODES[gamemode][1] or len(villagers) > var.GAME_MODES[gamemode][2] or var.GAME_MODES[gamemode][3] == 0:
|
||||
continue
|
||||
possiblegamemodes += [gamemode] * num
|
||||
numvotes += num
|
||||
if len(villagers) - numvotes > 0:
|
||||
possiblegamemodes += [None] * (len(villagers) - numvotes)
|
||||
# check if we go with a voted mode or a random mode
|
||||
gamemode = random.choice(possiblegamemodes)
|
||||
if gamemode is None:
|
||||
possiblegamemodes = []
|
||||
for gamemode in var.GAME_MODES.keys() - var.DISABLED_GAMEMODES:
|
||||
if len(villagers) >= var.GAME_MODES[gamemode][1] and len(villagers) <= var.GAME_MODES[gamemode][2] and var.GAME_MODES[gamemode][3] > 0:
|
||||
possiblegamemodes += [gamemode] * var.GAME_MODES[gamemode][3]
|
||||
gamemode = random.choice(possiblegamemodes)
|
||||
cgamemode(gamemode)
|
||||
|
||||
else:
|
||||
cgamemode(restart)
|
||||
|
Loading…
Reference in New Issue
Block a user