random hero selection generatot
Page 1 of 1
random hero selection generatot
Heyall,
here i post some pseudo-code on the random generator.
Current problems:
proposed fix:
plz make commments on the heal/ stun weights below here is a editable list
here is a python example:
import numpy as np
# number of stuns and heals that we desire ingame
targetNrOfStuns = 2.5
targetNrOfHeals = 1.5
NumberOfPlayers = 5 # players per team, possibly 6 later
WeightWeights=[1,1,1] # weight the impact of double hero, stun and heal modifier
# Alliance Hero stats matrix
# hero number # double-hero-weight # stun weight # heal weight # name
statsAlliance=np.array([
[ 1 , 1 , 0 , 0 ] , # potm
[ 2 , 1 , 0 , 0 ] , # ilidan
[ 3 , 0.8, 0.2, 0 ] , # warden
[ 4 , 1 , 0 , 0 ] , # pandaren wardancer
[ 5 , 1 , 0.8, 0.8] , # high elf
[ 6 , 1 , 0 , 0 ] , # samurai
[ 7 , 1 , 0 , 1 ] , # pala
[ 8 , 1 , 1.2, 0 ] , # mountain king
[ 9 , 1 , 0.3, 0 ] , # panda
[ 10 , 1 , 1 , 0.2] , # arthas
[ 11 , 0.5, 1 , 0 ] , # batman
[ 12 , 1 , 0 , 0 ] , # naga viper
[ 13 , 1 , 1.2, 0 ] , # barbarian
[ 14 , 1 , 1 , 0 ] , # tinker
[ 15 , 1 , 0.1, 0 ] , # bloodmage
[ 16 , 1 , 1 , 0 ] , # wizard
[ 17 , 1 , 1 , 0.3] , # kotg
[ 18 , 1 , 1 , 0 ] , # firelord
[ 19 , 1 , 1 , 0 ] , # ranger
[ 20 , 0.5, 0 , 1 ] , # kubi
[ 21 , 1 , 0.5, 0 ] , # naga queen
[ 22 , 0.8, 0.9, 1 ]]) # druid
# Horde Hero stats matrix
# hero number # double-hero-weight # stun weight # heal weight # name
statsHorde=np.array([
[ 1 , 0.5, 0 , 0 ] , # blademaster
[ 2 , 1 , 0 , 0 ] , # dark ranger
[ 3 , 0.8, 0 , 0 ] , # skeleton warden
[ 4 , 1 , 0 , 0 ] , # axemaster
[ 5 , 0.5, 0.8, 0.8] , # grim reaper
[ 6 , 1 , 0 , 0 ] , # naga???
[ 7 , 1 , 0 , 0.8] , # death knight
[ 8 , 1 , 1 , 0 ] , # tauren warrior
[ 9 , 1 , 0.5, 0 ] , # pitlord
[ 10 , 1 , 1 , 0 ] , # beasty
[ 11 , 0.5, 1 , 0 ] , # taure
[ 12 , 1 , 0 , 0 ] , # alchi
[ 13 , 1 , 1 , 0 ] , # crypt lord
[ 14 , 1 , 1 , 0 ] , # clown
[ 15 , 1 , 1.3, 0 ] , # dreadlord
[ 16 , 1 , 0 , 0 ] , # farseer
[ 17 , 0.8, 0.9, 1.2] , # shadowhunter
[ 18 , 1 , 0 , 0 ] , # zuul
[ 19 , 1 , 0.3, 0 ] , # lich
[ 20 , 1 , 0.5, 0 ] , # archimonde
[ 21 , 0.5, 0 , 1 ] , # kubi
[ 22 , 1 , 1 , 0 ]]) # nether mage
# alliance player now types "-random",
# the numbers of current heroes must be fetched (here hardcoded):
numbersOfSpawnedHeroes=np.array([7,22,1])
# = pala, druid and potm already on the field (hardcoded)
#assign alliance stats, less the already spawned heroes
stats=np.delete(statsAlliance,numbersOfSpawnedHeroes-1, axis=0)
SumStats=sum(stats[numbersOfSpawnedHeroes-1,2:])
# would be [2.8 stuns ,0.9 heals] now from pala, druid and potm
#now check how much is "left" to the desired number of stuns & heals
#taking into account the number of players (make heals & stuns not preferrably
# chosen for the first guy who makes -random)
SumDiff = (len(numbersOfSpawnedHeroes)/NumberOfPlayers) * \
(np.array([targetNrOfStuns,targetNrOfHeals])-SumStats)
#finally calculate the probability bias for each hero
chanceDouble = WeightWeights[0]*stats[:,1]
chanceStun = WeightWeights[1]*np.exp(stats[:,2]*SumDiff[0])
chanceHeal = WeightWeights[2]*np.exp(stats[:,3]*SumDiff[1])
bias=chanceDouble*chanceStun*chanceHeal
chance=bias*np.random.random(len(bias))
#aaaaand the winner is.....
WinnerIndex=chance.argmax()
#now spawn the winning hero
here i post some pseudo-code on the random generator.
Current problems:
- some heroes appear twice as often in the game than others.
- often, there is an imbalance with regard to stuns per team
- often, there is an imbalance with regard to healers per team
proposed fix:
- adjust random chances of double-heroes (kubi, tc/batman, High Elf/Grim Reaper...)
- make the random generator increase/decrease the likelyhood of selecting a stun hero, based on the heroes that already spawned
- make the random generator increase/decrease the likelyhood of selecting a healer, based on the heroes that already spawned
plz make commments on the heal/ stun weights below here is a editable list
- Code:
prepare table of heroe properties (double hero, stun weight, heal weight)
prepare number of desired heals & stuns in the game
for each -random spawn
get the combined stun and heal weights of all heroes that spawned already in the same team
determine the number of stuns & heals the next spawning hero should have based on the desired and actual (already spawned) numbers
convert the desired number of heals & stuns into a probability weight for each hero to be spawned
throw the dice
spawn winning hero
end for
here is a python example:
import numpy as np
# number of stuns and heals that we desire ingame
targetNrOfStuns = 2.5
targetNrOfHeals = 1.5
NumberOfPlayers = 5 # players per team, possibly 6 later
WeightWeights=[1,1,1] # weight the impact of double hero, stun and heal modifier
# Alliance Hero stats matrix
# hero number # double-hero-weight # stun weight # heal weight # name
statsAlliance=np.array([
[ 1 , 1 , 0 , 0 ] , # potm
[ 2 , 1 , 0 , 0 ] , # ilidan
[ 3 , 0.8, 0.2, 0 ] , # warden
[ 4 , 1 , 0 , 0 ] , # pandaren wardancer
[ 5 , 1 , 0.8, 0.8] , # high elf
[ 6 , 1 , 0 , 0 ] , # samurai
[ 7 , 1 , 0 , 1 ] , # pala
[ 8 , 1 , 1.2, 0 ] , # mountain king
[ 9 , 1 , 0.3, 0 ] , # panda
[ 10 , 1 , 1 , 0.2] , # arthas
[ 11 , 0.5, 1 , 0 ] , # batman
[ 12 , 1 , 0 , 0 ] , # naga viper
[ 13 , 1 , 1.2, 0 ] , # barbarian
[ 14 , 1 , 1 , 0 ] , # tinker
[ 15 , 1 , 0.1, 0 ] , # bloodmage
[ 16 , 1 , 1 , 0 ] , # wizard
[ 17 , 1 , 1 , 0.3] , # kotg
[ 18 , 1 , 1 , 0 ] , # firelord
[ 19 , 1 , 1 , 0 ] , # ranger
[ 20 , 0.5, 0 , 1 ] , # kubi
[ 21 , 1 , 0.5, 0 ] , # naga queen
[ 22 , 0.8, 0.9, 1 ]]) # druid
# Horde Hero stats matrix
# hero number # double-hero-weight # stun weight # heal weight # name
statsHorde=np.array([
[ 1 , 0.5, 0 , 0 ] , # blademaster
[ 2 , 1 , 0 , 0 ] , # dark ranger
[ 3 , 0.8, 0 , 0 ] , # skeleton warden
[ 4 , 1 , 0 , 0 ] , # axemaster
[ 5 , 0.5, 0.8, 0.8] , # grim reaper
[ 6 , 1 , 0 , 0 ] , # naga???
[ 7 , 1 , 0 , 0.8] , # death knight
[ 8 , 1 , 1 , 0 ] , # tauren warrior
[ 9 , 1 , 0.5, 0 ] , # pitlord
[ 10 , 1 , 1 , 0 ] , # beasty
[ 11 , 0.5, 1 , 0 ] , # taure
[ 12 , 1 , 0 , 0 ] , # alchi
[ 13 , 1 , 1 , 0 ] , # crypt lord
[ 14 , 1 , 1 , 0 ] , # clown
[ 15 , 1 , 1.3, 0 ] , # dreadlord
[ 16 , 1 , 0 , 0 ] , # farseer
[ 17 , 0.8, 0.9, 1.2] , # shadowhunter
[ 18 , 1 , 0 , 0 ] , # zuul
[ 19 , 1 , 0.3, 0 ] , # lich
[ 20 , 1 , 0.5, 0 ] , # archimonde
[ 21 , 0.5, 0 , 1 ] , # kubi
[ 22 , 1 , 1 , 0 ]]) # nether mage
# alliance player now types "-random",
# the numbers of current heroes must be fetched (here hardcoded):
numbersOfSpawnedHeroes=np.array([7,22,1])
# = pala, druid and potm already on the field (hardcoded)
#assign alliance stats, less the already spawned heroes
stats=np.delete(statsAlliance,numbersOfSpawnedHeroes-1, axis=0)
SumStats=sum(stats[numbersOfSpawnedHeroes-1,2:])
# would be [2.8 stuns ,0.9 heals] now from pala, druid and potm
#now check how much is "left" to the desired number of stuns & heals
#taking into account the number of players (make heals & stuns not preferrably
# chosen for the first guy who makes -random)
SumDiff = (len(numbersOfSpawnedHeroes)/NumberOfPlayers) * \
(np.array([targetNrOfStuns,targetNrOfHeals])-SumStats)
#finally calculate the probability bias for each hero
chanceDouble = WeightWeights[0]*stats[:,1]
chanceStun = WeightWeights[1]*np.exp(stats[:,2]*SumDiff[0])
chanceHeal = WeightWeights[2]*np.exp(stats[:,3]*SumDiff[1])
bias=chanceDouble*chanceStun*chanceHeal
chance=bias*np.random.random(len(bias))
#aaaaand the winner is.....
WinnerIndex=chance.argmax()
#now spawn the winning hero
Steel.DX- Dope
- Posts : 369
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|