Beispiel #1
0
size = len(brains)

SCORES = []

for brain in brains:
    snk.load_from(brain)
    snk.reburn()
    timeout = 0.0
    wall = 0.0
    Self = 0.0
    scoresum = 0.0
    for i in range(TIMES):
        while not snk.dead:
            snk.auto_play()
            snk.MOVE()
        if snk.deadReason == 'time out':
            timeout += 1
        if snk.deadReason == 'collisionWall':
            wall += 1
        if snk.deadReason == 'collisionSelf':
            Self += 1
        scoresum += snk.food_count
        snk.reburn()
    SCORES.append(scoresum)
    print("Snake:", brain, "timeout:", timeout / TIMES, 'collisionWall:',
          wall / TIMES, 'collisionSelf:', Self / TIMES, 'score:',
          scoresum / TIMES)

Rank = np.argsort(SCORES)
lens = len(Rank)