コード例 #1
0
ファイル: depth1.py プロジェクト: kspi/tron
    def decide(self, board, players, num):
        me = players[num]
        forward = apply_direction(me.position, me.direction)
        f = not board.is_wall(forward)
        left = apply_direction(me.position, new_direction(me.direction, player.TURN_LEFT))
        l = not board.is_wall(left)
        right = apply_direction(me.position, new_direction(me.direction, player.TURN_RIGHT))
        r = not board.is_wall(right)

        if f and l and r:
            return util.choose_randomly([
                (0.001, player.TURN_LEFT),
                (0.998, player.GO_FORWARD),
                (0.001, player.TURN_RIGHT),
            ])
        elif f and l or f and r:
            return util.choose_randomly([
                (0.999, player.GO_FORWARD),
                (0.001, player.TURN_LEFT if l else player.TURN_RIGHT),
            ])
        elif l and r:
            return util.choose_randomly([
                (0.5, player.TURN_LEFT),
                (0.5, player.TURN_RIGHT),
            ])
        elif l:
            return player.TURN_LEFT
        elif r:
            return player.TURN_RIGHT
        else:
            return player.GO_FORWARD
コード例 #2
0
ファイル: rand.py プロジェクト: kspi/tron
 def decide(self, board, me, her):
     return util.choose_randomly([
         (0.2, player.TURN_LEFT),
         (0.6, player.GO_FORWARD),
         (0.2, player.TURN_RIGHT),
     ])