Last active
October 3, 2019 06:50
-
-
Save fyr91/703cda744229a9ffd416f88fb5634bcd to your computer and use it in GitHub Desktop.
dummy ga
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dummy battle class | |
class Battle: | |
def __init__(self, lineup_a, lineup_b, result=None): | |
self.lineup_a = lineup_a | |
self.lineup_b = lineup_b | |
self.result = result | |
# fight - compare number of 1s in the gene | |
def fight(pair): | |
# save battle info for evaluation | |
battle = Battle(pair[0], pair[1]) | |
if pair[0].combat_power > pair[1].combat_power: | |
battle.result = 'win' | |
else: | |
battle.result = 'loss' | |
return battle | |
# evaluation | |
def evaluate(battle): | |
if battle.result == "win": | |
battle.lineup_a.score += 1 | |
battle.lineup_b.score -= 1 | |
else: | |
battle.lineup_a.score -= 1 | |
battle.lineup_b.score += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment