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


Python bot.Bot类代码示例

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


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

示例1: run

def run(N):
    """ Runs N episodes of a given length and then runs a demo with greedy policy
	"""
    agent = Agent()

    data = read_data('./data/q.dat')
    if data is not None:
        agent.Q = data

    for i in range(N):
        bot = Bot()
        run_episode(bot, agent, None, draw=False, policy='eps_greedy')
    # if bot.center[1] > 7: print "robot moved on: %i steps" % bot.center[1]

    pg.init()
    pg.display.init()
    surf = pg.display.set_mode((800, 600))
    surf.fill((0, 0, 0))
    pg.display.flip()
    print "Surf1:", surf

    bot = Bot()
    bot.info()
    run_episode(bot, agent, surf, draw=True, policy='eps_greedy', episode_len=60)
    print "Robot's moves:\n", bot.path
    print "Robot walked %i m" % bot.center[1]
    print "Last state value=%.1f" % agent.get_state_value(bot.get_state())
    write_data(agent.Q, "data/q.dat")
    write_path(agent.Q_values, "data/path.csv")
开发者ID:snigavig,项目名称:triptripod,代码行数:29,代码来源:run.py

示例2: add_bot

 def add_bot(self, name):
     bot = Bot(self)
     bot.name = name
     self.bots.append(bot)
     if self.running:
         bot.connect(self.host, self.port)
     return bot
开发者ID:Thoth19,项目名称:pygar,代码行数:7,代码来源:game.py

示例3: Spinner

class Spinner():
    """
    This is our spinner class, it's what keeps the bot alive.
    It will run until a QuitEvent has been sent out.
    It consumes the event dispatchers queue and then sleeps for 0.01 seconds to reduce overhead.
    """
    def __init__(self, parameters):
        fileName, self.coreFile, self.moduleFile, GUI = parameters;
        self.read_config("all")
        self.ed         = botinfo.bot_info["ed"] = eventdispatcher.EventDispatcher()
        self.alive      = True
        self.bot        = Bot(self.ed)
        self._connection = [
            self.ed.add(QuitEvent, Wbm(self.quit)),
            self.ed.add(ReloadconfigEvent, Wbm(self.read_config))
        ]
        self.bot.start()
        
    
    def tick(self):
        self.ed.consume_event_queue()
        return self.alive
        
    def quit(self, event):
        self.alive = False
        
    def read_config(self, event):
        botinfo.bot_info.update(botinfo.read_config("core", self.coreFile))
        botinfo.bot_info.update(botinfo.read_config("modules", self.moduleFile))
开发者ID:mbriden,项目名称:FatbotIRC,代码行数:29,代码来源:spinner.py

示例4: POST

 def POST(self):
   """ Handle request to get a bot's move """
   
   # Make sure responses aren't cached by client
   web.header('Content-Type', 'text/plain')
   web.header('Cache-Control', 'no-cache, no-store, no-transform')
   web.header('Expires', '0')
   web.header('Pragma', 'no-cache')
   
   if web.input()['state']:
     from state import State
     from move import COLLAPSE
     # Load the state of the game
     game = State(web.input()['state'])
     last_move = game.moves[-1]
     response = ""
     from bot import Bot
     # Is it the bot's turn?
     if not game.outcome and last_move and     \
           last_move.player == 1 and           \
           last_move.type != COLLAPSE:
       # if response = self.debug(game): return response
       response = Bot.play_move(game, int(web.input()['difficulty']))
     # Is the game over?
     if game.outcome: Bot.learn(game)
     return response
开发者ID:Andarin,项目名称:qtpy,代码行数:26,代码来源:getmove.py

示例5: process_message

def process_message(self, messageId):
    try:
        messageInst = MessageTask.objects.get(pk=messageId)

        if not messageInst.message.startswith(BOT_USERNAME_PREFIX):
            return False

        bot = Bot()
        command = bot.get_own_command(messageInst.message)

        if command:
            try:
                response = command(message=messageInst.message, fromMessageId=messageInst.pk).run()
            except KeyboardInterrupt as ex:
                response = str(ex)
        else:
            response = "Command not found"

        MessageTask.objects.create(
            c_dest=MessageTask.C_DEST_OUTGOING,
            message=response,
            user = messageInst.user,
            respond_to=messageInst
        )
    except MessageTask.DoesNotExist:
        return False
开发者ID:a1fred,项目名称:grissli_test,代码行数:26,代码来源:tasks.py

示例6: main

def main():

    # run this from the home
    # https://www.facebook.com/appcenter/diamonddash?
    # fb_source=appcenter_getting_started&fbsid=114
    # with firefox at default zoom (cmd+0 -> default zoom)
    play_button = match('imgs/play.png')
    if play_button:
        #bottom_right = [play_button[0] - 61, play_button[1] + 102]
        #top_left = [play_button[0] - 463, play_button[1] - 258]
        mouseclick(play_button[0], play_button[1])
        mouseclick(play_button[0], play_button[1])
        time.sleep(3)
        play_button = match('imgs/play2.png')
        if play_button:
            mouseclick(play_button[0], play_button[1])

    bottom_right = [486, 686]
    top_left = [86, 326]
    # the game has started
    time.sleep(4)
    print 'start'
    # get top left point and bottom right
    diamond_width = (bottom_right[0] - top_left[0]) / (GRID_WIDTH)
    diamond_height = (bottom_right[1] - top_left[1]) / (GRID_HEIGHT)

    b = Bot(
        #[top_left[0] - diamond_width / 2, top_left[1] - diamond_height / 2],
        [top_left[0], top_left[1]],
        GRID_WIDTH, GRID_HEIGHT, diamond_width, diamond_height,
        SENSITIVITY, COUNTER_THRESHOLD)
    while b.running:
        b.next()
开发者ID:dnlcrl,项目名称:Pydiamond,代码行数:33,代码来源:main.py

示例7: onSourceRowChanged

	def onSourceRowChanged(self, sourceModel, sourcePath, sourceIter):
		# get needed values from source model
		try:
			sourceRow = sourceModel[sourceIter]
			sourceRowName = sourceRow[SettingModel.COLUMN_NAME]
		except ValueError:
			return
		# update reference to bots-row
		if sourceRow.parent == None and sourceRowName == SettingModel.ROW_BOTS:
			self.botsRowReference = gtk.TreeRowReference(sourceModel, sourceRow.path)
		# check that the changed row is a bot row, ignore others
		if sourceRow.parent != None and self.botsRowReference != None and sourceRow.parent.path == self.botsRowReference.get_path():
			bot = None
			# try to find an existing bot
			for row in self:
				if sourceRow.path == row[self.COLUMN_SOURCEROWREFERENCE].get_path():
					bot = row[self.COLUMN_BOTOBJECT]
					break
			# if bot was found, update it
			if bot:
				if bot.getName() != sourceRowName:
					raise NotImplementedError('Changing bot name is not implemented')
			# if bot was not found, create it
			else:
				bot = Bot(sourceRowName, self.sourceModel)
				bot.connect('notify::apiAccessible', self.onBotPropertyChanged)
				bot.connect('notify::isRunning', self.onBotPropertyChanged)
				sourceRef = gtk.TreeRowReference(sourceModel, sourceRow.path)
				self.append((bot, sourceRef))
开发者ID:farthing,项目名称:Budabot,代码行数:29,代码来源:botmodel.py

示例8: on_message

 def on_message(self, data):
     """
     Callback when new message received vie the socket.
     """
     logging.info('Received new message %r', data)
     
     #noone can write in the "rooms"
     if self.room == 'rooms' or self.room == 'help':
         return
     
     
     try:
         # Parse input to message dict.
         datadecoded = tornado.escape.json_decode(data)
         message = {
             '_id': ''.join(random.choice(string.ascii_uppercase) for i in range(12)),
             #'from': self.get_secure_cookie('user', str(datadecoded['user'])),
             'from': self.application.usernames[self.get_secure_cookie('user')],
             'body': tornado.escape.linkify(datadecoded["body"]),
         }
         if not message['from']:
             logging.warning("Error: Authentication missing")
             message['from'] = 'Guest'
             
         if str(message['body'])[0] == '!':
             box_bot = Bot(self)
             box_bot.makeBot(message)
             return
         
     except Exception, err:
         # Send an error back to client.
         self.write_message({'error': 1, 'textStatus': 'Bad input data ... ' + str(err) + data})
         return
开发者ID:nislag,项目名称:chat-bot-tornado,代码行数:33,代码来源:app.py

示例9: main

def main():
    bot = Bot(BTSUSERNAME, BTSPASSWORD, activeDate=date(2014,8,1))
    # bot.choose_players(p1=('Victor', 'Martinez', 'det'), p2=())
    # import pdb
    # pdb.set_trace()
    bot.choose_players( p1=('Denard', 'Span', 'wsh'), 
                        p2=())
开发者ID:frahman5,项目名称:beatthestreakBots,代码行数:7,代码来源:quicktest.py

示例10: test_noun_verb2

	def test_noun_verb2(self):
		bot = Bot()
		bot_input = "David is running quickly"
		bot.tell(bot_input)
		verbs = bot.knowledge.get_verbs()
		verb = verbs[0]
		self.assertEqual(verb.word, "running")
开发者ID:AxelUlmestig,项目名称:chatterbot,代码行数:7,代码来源:pattern_tests.py

示例11: test_noun_is_noun_false

	def test_noun_is_noun_false(self):
		bot = Bot()
		bot_input1 = "the giraffe is an animal"
		bot_input2 = "the animal is a giraffe"
		expected_response = "That is impossible."
		bot.tell(bot_input1)
		response = bot.tell(bot_input2)
		self.assertEqual(response, expected_response)
开发者ID:AxelUlmestig,项目名称:chatterbot,代码行数:8,代码来源:pattern_tests.py

示例12: test_person_adj_inquiry_false

	def test_person_adj_inquiry_false(self):
		bot = Bot()
		bot_input1 = "David is sweet"
		bot_input2 = "is David cute?"
		expected_response = "I don't have that information."
		bot.tell(bot_input1)
		response = bot.tell(bot_input2)
		self.assertEqual(response, expected_response)
开发者ID:AxelUlmestig,项目名称:chatterbot,代码行数:8,代码来源:pattern_tests.py

示例13: test_person_adj_inquiry_true

	def test_person_adj_inquiry_true(self):
		bot = Bot()
		bot_input1 = "David is cute"
		bot_input2 = "is David cute?"
		expected_response = "Yes."
		bot.tell(bot_input1)
		response = bot.tell(bot_input2)
		self.assertEqual(response, expected_response)
开发者ID:AxelUlmestig,项目名称:chatterbot,代码行数:8,代码来源:pattern_tests.py

示例14: test_noun_verb_inquiry_false2

	def test_noun_verb_inquiry_false2(self):
		bot = Bot()
		bot_input1 = "David is hugging a tomato"
		bot_input2 = "Is David hugging a cucumber?"
		expected_response = "No."
		bot.tell(bot_input1)
		response = bot.tell(bot_input2)
		self.assertEqual(response, expected_response)
开发者ID:AxelUlmestig,项目名称:chatterbot,代码行数:8,代码来源:pattern_tests.py

示例15: test_noun_verb_inquiry_false1

	def test_noun_verb_inquiry_false1(self):
		bot = Bot()
		bot_input1 = "David is running quickly"
		bot_input2 = "Is David eating?"
		expected_response = "No."
		bot.tell(bot_input1)
		response = bot.tell(bot_input2)
		self.assertEqual(response, expected_response)
开发者ID:AxelUlmestig,项目名称:chatterbot,代码行数:8,代码来源:pattern_tests.py


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