Removed randomness from entity picking
This commit is contained in:
parent
de68c5e991
commit
dc5dc756cb
20
src/AI/GA.py
20
src/AI/GA.py
@ -207,15 +207,23 @@ def pickEntity(player, map):
|
|||||||
|
|
||||||
# Pick best weighted entities
|
# Pick best weighted entities
|
||||||
bestIdxs = (numpy.where(finalWeights == numpy.max(finalWeights)))[0]
|
bestIdxs = (numpy.where(finalWeights == numpy.max(finalWeights)))[0]
|
||||||
bestEntities = []
|
# bestEntities = []
|
||||||
for i in bestIdxs:
|
# for i in bestIdxs:
|
||||||
bestEntities.append(finalEntities[i])
|
# bestEntities.append(finalEntities[i])
|
||||||
|
|
||||||
choice = random.choice(bestEntities)
|
choice = finalEntities[bestIdxs[0]]
|
||||||
|
|
||||||
# Keeps the player from standing still
|
# If the choice happens to be the same as the last one
|
||||||
if choice == map.getEntityOnCoord(player.getFacingCoord()):
|
if choice == map.getEntityOnCoord(player.getFacingCoord()):
|
||||||
choice = random.choice(finalEntities)
|
del finalWeights[bestIdxs[0]]
|
||||||
|
del finalEntities[bestIdxs[0]]
|
||||||
|
|
||||||
|
secondBestIdxs = (numpy.where(finalWeights == numpy.max(finalWeights)))[0]
|
||||||
|
# bestEntities = []
|
||||||
|
# for i in secondBestIdxs:
|
||||||
|
# bestEntities.append(finalEntities[i])
|
||||||
|
|
||||||
|
choice = finalEntities[secondBestIdxs[0]]
|
||||||
# Old method using RNG
|
# Old method using RNG
|
||||||
# choice = random.choices(finalEntities, finalWeights)[0]
|
# choice = random.choices(finalEntities, finalWeights)[0]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user