當前位置: 首頁>>代碼示例>>Python>>正文


Python Timer.timer方法代碼示例

本文整理匯總了Python中utils.Timer.timer方法的典型用法代碼示例。如果您正苦於以下問題:Python Timer.timer方法的具體用法?Python Timer.timer怎麽用?Python Timer.timer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utils.Timer的用法示例。


在下文中一共展示了Timer.timer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update_display

# 需要導入模塊: from utils import Timer [as 別名]
# 或者: from utils.Timer import timer [as 別名]
    def update_display(self, elevators, floors):

        # elevator positions
        for i, e in enumerate(elevators):
            self.print_elevator(i, e.old_pos, c=" " * (len(str(e)) + 2))
            self.print_elevator(i, e.pos, c=str(e), color=e.state)

        # rider counds
        for f in xrange(len(floors)):
            m = len(floors[f])
            self.screen.print_at(" " * 20, self.frame_x + 2, self.frame_y + self.frame_h - 2 - f)

            label = "{:<10}{:<3}({})".format("*" * min(m, 10), "..." if m > 10 else "", m)
            self.screen.print_at(label, self.frame_x + 2, self.frame_y + self.frame_h - 2 - f)

        # stats:
        self.screen.print_at(" " * self.frame_w, self.frame_x, self.frame_y - 1)
        self.screen.print_at(
            "Time: {:<6.1f}, Produced: {:<6}, Delivered: {:<6} ({:<2.0f}%), Died: {:<6} ({:2.0f}%)".format(
                Timer.timer(self.game).time(),
                self.game.produced,
                self.game.delivered,
                100.0 * self.game.delivered / self.game.produced,
                self.game.died,
                100.0 * self.game.died / self.game.produced,
            ),
            self.frame_x,
            self.frame_y - 1,
        )

        self.screen.refresh()
開發者ID:yuribak,項目名稱:pylevator,代碼行數:33,代碼來源:elev.py

示例2: __init__

# 需要導入模塊: from utils import Timer [as 別名]
# 或者: from utils.Timer import timer [as 別名]
    def __init__(self, screen, floor_count, elev_count, life_expectancy, rps):

        self.life_expectancy = life_expectancy
        self.rps = rps

        self.display = Display(screen, floor_count, elev_count, self)

        self.floors = [list() for _ in xrange(floor_count)]
        self.elevators = [Elevator(random.randint(0, floor_count - 1)) for _ in xrange(elev_count)]

        self.timer = Timer.timer(self)

        self.delivered = 0
        self.produced = 0
        self.died = 0
開發者ID:yuribak,項目名稱:pylevator,代碼行數:17,代碼來源:elev.py

示例3: main

# 需要導入模塊: from utils import Timer [as 別名]
# 或者: from utils.Timer import timer [as 別名]
    def main(s):

        g = Game(s, floor_count, elev_count, life_expectancy, rps)

        t = Timer.timer(g)

        while t.time() < game_time:

            current_frame = t.time()

            g.update()

            d = game_second - (t.time() - current_frame)
            if d > 0:
                if fast_mode:
                    t.skip(d)
                else:
                    sleep(d)
開發者ID:yuribak,項目名稱:pylevator,代碼行數:20,代碼來源:elev.py


注:本文中的utils.Timer.timer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。