当前位置: 首页>>代码示例>>Python>>正文


Python game.Game类代码示例

本文整理汇总了Python中lib.game.Game的典型用法代码示例。如果您正苦于以下问题:Python Game类的具体用法?Python Game怎么用?Python Game使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Game类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_contestant_can_switch

 def test_contestant_can_switch(self):
     door_1, door_2, door_3 = Door(False), Door(True), Door(False)
     game = Game(door_1, door_2, door_3)
     game.contestant_guess = door_1
     game.contestant_switch()
     self.assertNotEqual(door_1, game.contestant_guess)
     self.assertIsInstance(game.contestant_guess, Door)
开发者ID:richardbatty,项目名称:monty_hall,代码行数:7,代码来源:game_test.py

示例2: __init__

class Bot:

    def __init__(self, config):
        self.config = config
        self.irc = Irc(config)
        self.game = Game()

    def run(self):
        last_start = time.time()

        while True:
            new_messages = self.irc.recv_messages(1024)
            
            if new_messages:
                for message in new_messages:
                    button = message['message'].lower()
                    username = message['username']

                    if not self.game.is_valid_button(button):
                        continue

                    if self.config['start_throttle']['enabled'] and button == 'start':
                        if time.time() - last_start < self.config['start_throttle']['time']:
                            continue

                    pbutton(username, button)
                    self.game.push_button(button)

                    if button == 'start':
                        last_start = time.time()
开发者ID:JamieMagee,项目名称:twitch-plays,代码行数:30,代码来源:bot.py

示例3: test_case_where_contestant_guesses_correctly

 def test_case_where_contestant_guesses_correctly(self):
     door_1, door_2, door_3 = Door(False), Door(True), Door(False)
     game = Game(door_1, door_2, door_3)
     game.contestant_guess = door_2
     game.host_open_door()
     self.assertEqual(False, door_2.is_open)
     self.assertEqual(True, door_1.is_open ^ door_3.is_open)
开发者ID:richardbatty,项目名称:monty_hall,代码行数:7,代码来源:game_test.py

示例4: test_play_states_when_the_player_wins

def test_play_states_when_the_player_wins(mocker):
   mocker.patch('lib.console.display')
   mocker.patch('lib.player_input.read_choice', return_value="p")
   mocker.patch('lib.computer_input.read_choice', return_value="r")

   Game.play()

   lib.console.display.assert_any_call("Player wins!")
开发者ID:caspian311,项目名称:python-rock-paper-scissors,代码行数:8,代码来源:game_test.py

示例5: test_drop_piece_returns_final_position

 def test_drop_piece_returns_final_position(self):
     g = Game() # 6x7 by default
     self.assertEquals(g._drop_piece('X', 0), (0,5))
     self.assertEquals(g._drop_piece('X', 0), (0,4))
     self.assertEquals(g._drop_piece('X', 0), (0,3))
     self.assertEquals(g._drop_piece('O', 0), (0,2))
     self.assertEquals(g._drop_piece('X', 0), (0,1))
     self.assertEquals(g._drop_piece('X', 0), (0,0))
开发者ID:cabello,项目名称:connect-four,代码行数:8,代码来源:game_test.py

示例6: test_play_states_when_a_tie_occurres

def test_play_states_when_a_tie_occurres(mocker):
   mocker.patch('lib.console.display')
   mocker.patch('lib.player_input.read_choice', return_value="r")
   mocker.patch('lib.computer_input.read_choice', return_value="r")

   Game.play()

   lib.console.display.assert_any_call("It's a tie!")
开发者ID:caspian311,项目名称:python-rock-paper-scissors,代码行数:8,代码来源:game_test.py

示例7: test_play_computers_choice_is_displayed_if_computer_picks_other_option

def test_play_computers_choice_is_displayed_if_computer_picks_other_option(mocker):
   mocker.patch('lib.console.display')
   mocker.patch('lib.console.display_no_newline')
   mocker.patch('lib.player_input.read_choice')
   mocker.patch('lib.computer_input.read_choice', return_value="r")

   Game.play()

   lib.console.display.assert_any_call("Computer played Rock!")
开发者ID:caspian311,项目名称:python-rock-paper-scissors,代码行数:9,代码来源:game_test.py

示例8: test_play_computers_choice_is_displayed

def test_play_computers_choice_is_displayed(mocker):
   mocker.patch('lib.console.display')
   mocker.patch('lib.console.display_no_newline')
   mocker.patch('lib.player_input.read_choice')
   mocker.patch('lib.computer_input.read_choice', return_value="p")

   Game.play()

   lib.console.display.assert_any_call("Computer played Paper!")
开发者ID:caspian311,项目名称:python-rock-paper-scissors,代码行数:9,代码来源:game_test.py

示例9: test_play_prompts_for_users_option

def test_play_prompts_for_users_option(mocker):
   mocker.patch('lib.console.display')
   mocker.patch('lib.console.display_no_newline')
   mocker.patch('lib.player_input.read_choice')
   mocker.patch('lib.computer_input.read_choice')

   Game.play()

   lib.console.display.assert_any_call("Rock (r), Paper (p) or Scissors (s):")
开发者ID:caspian311,项目名称:python-rock-paper-scissors,代码行数:9,代码来源:game_test.py

示例10: test_get_pieces

 def test_get_pieces(self):
     g = Game(rows=1)
     g.drop_cross(0)
     g.drop_round(1)
     self.assertTrue((0,0) in g._get_pieces('X'))
     self.assertFalse((1,0) in g._get_pieces('X'))
     self.assertTrue((1,0) in g._get_pieces('O'))
     self.assertFalse((0,0) in g._get_pieces('O'))
开发者ID:cabello,项目名称:connect-four,代码行数:8,代码来源:game_test.py

示例11: test_dealCardsDealsCorrectly

 def test_dealCardsDealsCorrectly(self):
     deck = Deck()
     game = Game('SomeGameName', self.m)
     game.addPlayer(self.j)  # This isn't really necessary.
     game.dealCards([self.m, self.j], deck)
     self.assertEqual(self.m.hand.size(), 3)
     self.assertEqual(self.m.up.size(), 3)
     self.assertEqual(self.m.down.size(), 3)
     self.assertEqual(self.j.hand.size(), 3)
     self.assertEqual(self.j.up.size(), 3)
     self.assertEqual(self.m.down.size(), 3)
     self.assertEqual(deck.size(), (52 - 18))
开发者ID:mcpate,项目名称:CS594-GameProtocol,代码行数:12,代码来源:game_unittest.py

示例12: __init__

 def __init__(self):
     self.config = config
     self.irc = Irc(config)
     self.game = Game()
     self.extConfig=configparser.ConfigParser()
     self.message_buffer = deque(' ',self.bufferLength) #deque happens to be marginally more convenient for this
     self.curQueue=comQueue() #Based on Queue object, and therefore threadsafe
     self.daQueue=demAnQueue() #Based on deque object, and therefore threadsafe
     self.queueStatus="Nominal"
     self.lastButton=""
     self.voteCount={}
     self.lastPushed=""
     self.voteItems=self.voteCount.items() #Dynamically changing list in python 3 that keeps up with voteCount
     self.democracy=False #Anarchy is default on.
     self.game.democracy=self.democracy #Command processor needs this information due to slightly different processing in democracy vs. anarchy
     self.lastConfigTime=time.time() #Timer on config file updates
     self.configUpdateFreq=60 #config file updates every 60 seconds
     
     ###DEFAULT VALUES (should be overwritten by readConfigText() at the end###
     self.botConfig={'votetime':20,
         'checktime':0.1,
         'votethresh':75}
     ###END DEFAULT VALUES###
     
     self.readConfigText() #read in config file (after all possible object initializations)
     self.daQueue.updateQueue() #It's poor form that I have to do this, but it's cleanest
开发者ID:cicero225,项目名称:twitch-plays,代码行数:26,代码来源:bot.py

示例13: __init__

 def __init__(self):
     self.config = config
     self.irc = Irc(config)
     self.game = Game()
     self.stats = Stats()
     if self.config['features']['gui_stats']:
         self.GUI = GUI(self)
开发者ID:xblink,项目名称:twitch-plays-stats,代码行数:7,代码来源:bot.py

示例14: __init__

 def __init__(self):
     self.config = config
     self.irc = Irc(config)
     self.game = Game()
     self.message_buffer = []
     self.scrolling_chat = []
     self.chat_buffer = []
     self.game_tracker = [0,0,0,0,0,0,0,0,0]
     self.windowSurface = pygame.display.set_mode((1300,800), 0, 32)
     self.BLACK = (0,0,0)
     self.WHITE = (255,255,255)
     self.start = time.clock()
     self.game_timer = 0
     self.old_time = 0;
     self.xwins = 0
     self.owins = 0
     self.cats_games = 0
     self.games = 0
     self.who_starts = 0
     self.whos_move = 0
     self.suspend = 0
     self.winner = False
     self.is_cats = False
     self.music = pygame.mixer.Sound('music_loop.wav')
     self.basicFont = pygame.font.SysFont(None, 36)
开发者ID:travman89,项目名称:TwitchPlaysTicTacToe,代码行数:25,代码来源:bot.py

示例15: test_rotatesPlayersCorrectly

 def test_rotatesPlayersCorrectly(self):
     game = Game("SomeGameName", self.m)
     game.addPlayer(self.j)
     game.beginGame()
     self.assertRegex(game.currentPlayer.name, self.j.name)
     game.rotateCurrentPlayer()
     self.assertRegex(game.currentPlayer.name, self.m.name)
开发者ID:mcpate,项目名称:CS594-GameProtocol,代码行数:7,代码来源:game_unittest.py


注:本文中的lib.game.Game类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。