• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rg.toward函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: act

 def act(self, game):
     self.game = game
     enemy_location = self.closest_adjacent_enemy()
     if 'spawn' in rg.loc_types(self.location):
         destinations = rg.locs_around(self.location, filter_out=('invalid','obstacle','spawn'))
         if destinations:
             # print("Robot {0}: In a spawn. Moving to {1}".format(str(self.location), str(destination)))
             return self.move(destinations[0])
         else:
             return self.guard()
     elif enemy_location:
         # print("Robot {0}:Trying to attack. Location:{1}".format(str(self.location), str(enemy_location)))
         return self.attack(enemy_location)
     else:
         enemies = []
         for loc, robot in game.robots.items():
             if robot.player_id != self.player_id:
                 enemies.append(loc)
         enemies.sort()
         if rg.toward(self.location, enemies[0]) == self.location:
             # print("Robot {0}:Don't want to collide; guarding.".format(self.location))
             return self.guard()
         else:
             destination = rg.toward(self.location, enemies[0])
             # print("Robot {0}: Not in position; moving to {1}.".format(self.location, destination))
             if 'spawn' not in rg.loc_types(destination):
                 return self.move(rg.toward(self.location, enemies[0]))
             else:
                 return self.move(rg.toward(self.location, rg.CENTER_POINT))
开发者ID:joeletizia,项目名称:robots,代码行数:29,代码来源:luke_strat.py


示例2: act

 def act(self, game):
     
     print
     print "Turn: " +str( game.turn) + "\tBot: " + str(self.robot_id)
     # find closest friend & enemy
     closestFriend = (1000, 1000)
     closestEnemy = (1000, 1000)
     for loc, bot in game.get('robots').items():
         if bot.player_id != self.player_id:
             if rg.wdist(loc, self.location) <= rg.wdist(closestEnemy, self.location):
                 closestEnemy = loc
         else:
             if rg.wdist(loc, self.location) <= rg.wdist(closestFriend, self.location) and self.robot_id != bot.robot_id:
                 closestFriend = loc
     
     for loc, bot in game['robots'].iteritems():
         # if there are enemies around, attack them
         if bot.player_id != self.player_id:
             if rg.dist(loc, self.location) <= 1:
                 return ['attack', loc]
         else:
             # if there are friends around, move to them
             if rg.dist(loc, self.location) > 2:
                 return ['move', rg.toward(self.location, closestFriend)]
                 
     # move towards enemy
     return ['move', rg.toward(self.location, closestEnemy)]
开发者ID:jwygralak67,项目名称:robots,代码行数:27,代码来源:darbot002.py


示例3: act

    def act(self, game):
        self.game = game
        max_angry = 10
        angry = 8
        is_angry = random.choice([True]*angry+[False]*(max_angry-angry))


        local_enemies = self.local_enemies(game)
        empty_spaces = [e for e in self.local_spaces()
                        if e not in local_enemies.keys()]

        if local_enemies:
            if self.hp < 10 and len(local_enemies) > 1:
                return ['suicide']

            if is_angry:
                return ['attack', random.choice(local_enemies.keys())]
            if empty_spaces:
                return ['move', random.choice(empty_spaces)]
            return['guard']

        enemies = self.enemies(game)

        for enemy in enemies:
            displacement = (self.location, enemy.location)
            if rg.wdist(*displacement) == 2:
                attack_loc = rg.toward(*displacement)
                if is_angry:
                    return ['move', attack_loc]
                if self.in_square(attack_loc) != 'friend':
                    return ['attack', attack_loc]

        return ['move', rg.toward(self.location,
                                  random.choice(self.enemies(game)).location)]
开发者ID:hwayne,项目名称:robotfight,代码行数:34,代码来源:angrybot.py


示例4: act

    def act(self, game):
        my_team = self.player_id
        if 'spawn' in rg.loc_types(self.location):
            # Store the position of the spawning point
            self.spawn_loc = self.location
            # Just move one place toward the center
            return ['move', rg.toward(self.location, rg.CENTER_POINT)]
        else:
            # Get the nearby locations
            near_locations = rg.locs_around(self.location)
            # For each location see if there is a robot there or not...
            for loc in near_locations:
                try:
                    robot_location = game.robots[loc]
                    # There is...

                    # TODO AR: there is problem. When robots from our team are near to each other
                    # they start moving to the center. in late phases of game it will be more often.

                    # If it is our own robot, just move to the center one step. If we are more than 1 distance from the spawning location, stop moving.
                    # this is to avoid moving to the center.
                    #if game.robots[loc]['player_id'] == my_team and self.location != rg.CENTER_POINT: 
                    if game.robots[loc]['player_id'] == my_team and rg.wdist(self.location,self.spawn_loc) == 1:
                        return ['move', rg.toward(self.location, rg.CENTER_POINT)]
                    # Just to take advantage of the situation, if there is an enemy near, attack it.
                    elif game.robots[loc]['player_id'] != my_team:
                        return ['attack', loc ]
                except KeyError:
                    # There are no robots there...
                    pass 

        return ['guard']
开发者ID:eldraco,项目名称:robotgames-robots,代码行数:32,代码来源:aaeBot7.py


示例5: act

    def act(self, game):
        
        # wszystkie pola
        wszystkie = {(x, y) for x in xrange(19) for y in xrange(19)}
        # punkty wejścia
        wejscia = {poz for poz in wszystkie if 'spawn' in rg.loc_types(poz)}
        # pola zablokowane
        zablokowane = {poz for poz in wszystkie if 'obstacle' in rg.loc_types(poz)}
        # pola zajęte przez nasze roboty
        przyjaciele = {poz for poz in game.robots if game.robots[poz].player_id == self.player_id}
        # pola zajęte przez wrogów
        wrogowie = set(game.robots) - przyjaciele
        # pola sąsiednie
        sasiednie = set(rg.locs_around(self.location)) - zablokowane
        # pola sąsiednie zajęte przez wrogów
        wrogowie_obok = sasiednie & wrogowie

        # działanie domyślne:
        ruch = ['move', rg.toward(self.location, rg.CENTER_POINT)]

        # jeżeli jesteś w punkcie wejścia, opuść go
        if self.location in wejscia:
            ruch = ['move', rg.toward(self.location, rg.CENTER_POINT)]

        # jeżeli jesteś w środku, broń się
        if self.location == rg.CENTER_POINT:
            ruch = ['guard']

        # jeżeli obok są przeciwnicy, atakuj
        if wrogowie_obok:
            ruch = ['attack', wrogowie_obok.pop()]

        return ruch
开发者ID:EdwardBetts,项目名称:python101,代码行数:33,代码来源:rgkod05b.py


示例6: act

 def act(self, game):
     active_team = {}
     active_enemy = {}
     enemy_distance = {}
     active_bots = {}
     for loc, bot in game.get('robots').items():
         if bot.player_id != self.player_id:
             active_enemy[loc] = bot                
             enemy_distance[loc] = 0
         else:
             active_team[loc] = bot
     for loc, bot in game.get('robots').items():
         active_bots[loc] = bot
     for loc in active_enemy:
         for myloc in active_team:
             enemy_distance[loc] = enemy_distance[loc] + rg.dist(loc, myloc)
     if self.hp <= 20:
         return flee(self, active_enemy, active_team, game)
     if 'spawn' in rg.loc_types(self.location):
         if game['turn'] %10 == 0: #spawn about to happen, gtfo
             return ['move', rg.toward(self.location, rg.CENTER_POINT)]
     for loc, bot in game['robots'].iteritems():
         if bot.player_id != self.player_id:
             if rg.dist(loc, self.location) <= 1:
                 print("ATTACK")
                 return ['attack', loc]
             else:                    
                 return['move', rg.toward(self.location, bot.location)]
开发者ID:hayksaakian,项目名称:otherbots,代码行数:28,代码来源:classhamster.py


示例7: act

  def act(self, game):
    blob_locs = set(self.location)
   
    #if one nearby enemy, attack
    #if surrounded by enemies, suicide
    #in between, run towards center.
    adj_enemies = []
    for l in set(rg.locs_around(self.location, ['spawn', 'invalid'])).difference(blob_locs):
      if l in game.get('robots').keys():
        if game['robots'][l].get('player_id') != self.player_id:
          adj_enemies.append(game['robots'][l])
    if len(adj_enemies) >= 4:
      return ['suicide']
    elif len(adj_enemies) > 1:
      #if in center, stand and fight lowest hp enemy 
      if self.location == rg.CENTER_POINT:
        target = min(adj_enemies, key=lambda k: k['hp']) 
        return['attack', target['location']]
      else:
        return ['move', rg.toward(self.location, rg.CENTER_POINT)]
    elif len(adj_enemies) == 1:
      return ['attack', adj_enemies[0]['location']]

    #hold the center
    if self.location == rg.CENTER_POINT:
      return ['guard']
    elif self.in_blob(self.location, blob_locs, game) and rg.CENTER_POINT in blob_locs:
      return ['guard']

    #don't hang around spawn points
    if 'spawn' in rg.loc_types(self.location):
      return ['move', rg.toward(self.location, rg.CENTER_POINT)]

    #if nothing better to do, move toward center.
    return ['move', rg.toward(self.location, rg.CENTER_POINT)]
开发者ID:nthall,项目名称:robotgame,代码行数:35,代码来源:bulleit.py


示例8: act

	def act(self, game):
		x,y = self.location
		bot = None
		active_team = {}
		active_enemy = {}
		enemy_distance  = {}
		for loc, bot in game.get('robots').items():
			if bot.get('player_id') != self.player_id:
				active_enemy[loc] = bot
				enemy_distance[loc] = 0
			else:
				active_team[loc] = bot
		for loc in active_enemy:
			for myloc in active_team:
				enemy_distance[loc] = enemy_distance[loc] + rg.dist(loc, myloc)
		prio_loc, attack_loc = self.findPriority(active_team, active_enemy,enemy_distance)
		distance_to_prio = rg.dist(self.location,prio_loc)
		distance_to_attack = BIG_DIST
		if attack_loc:
			distance_to_attack = rg.dist(self.location,attack_loc)
			if distance_to_attack<=1:
				return ['attack', attack_loc]
			else:
				return ['move', rg.toward(self.location, prio_loc)]
		else:
			if prio_loc == self.location:
				if self.hp < SELF_CRITICAL:
					return ['suicide']
				return ['guard']
			return ['move',rg.toward(self.location,prio_loc)]
		return ['guard']
开发者ID:Sebsebeleb,项目名称:TapionRobotGame,代码行数:31,代码来源:Tapion_Body.py


示例9: act

    def act(self, game):
        ennemies_around = []
        toward_center_location = rg.toward(self.location, rg.CENTER_POINT)
        
        for location, bot in game.robots.iteritems():
            if bot.player_id != self.player_id:
                if rg.dist(location, self.location) <= 1:
                    ennemies_around.append(location)

            if location == toward_center_location:
                if bot.player_id == self.player_id:
                    return ['guard']
                    

        if len(ennemies_around) > 2:
            return ['suicide']
        if len(ennemies_around) > 0:
            return ['attack', ennemies_around[0]]

        for location, bot in game.robots.iteritems():
            if bot.player_id == self.player_id:
                if self.give_way(location, toward_center_location):
                    print location, toward_center_location, self.location
                    return ['guard']

        return ['move', rg.toward(self.location, rg.CENTER_POINT)]
开发者ID:hjwp,项目名称:ldnpydojorobots,代码行数:26,代码来源:t4_is_cross.py


示例10: act

    def act(self, game):
        if self.robot_id in self.mayday:
            del self.mayday[self.robot_id]
        
        if self.hp < 10:
            return self.kill_self(game)

        enemies = []
        friends = []

        for robot in game.robots.itervalues():
            if hasattr(robot, "robot_id"):
                friends.append(robot)
            else:
                enemies.append(robot)

        targets = []
        for enemy in enemies:
            targets.append((enemy, rg.wdist(self.location, enemy.location)))

        target, distance = min(targets, key=lambda (a, b): b)

        if distance == 1:
            self.mayday[self.robot_id] = target.location
            return ["attack", target.location]
        if self.mayday:
            targets = [(t, rg.wdist(self.location, t)) for t in self.mayday.values()]
            target, _ = min(targets, key=lambda (a, b): b)
            if rg.wdist(self.location, target) == 1:
                return ["attack", target]
            return ["move", rg.toward(self.location, target)]
        return ["move", rg.toward(self.location, target.location)]
开发者ID:hjwp,项目名称:ldnpydojorobots,代码行数:32,代码来源:arnold.py


示例11: act

    def act(self, game):
        # TODO:
        # Swarm around the sub-leader bot
        # attack in group, increase radius of search to 2-3 tiles away
        
        #print " robot {} has moves ".format(self.robot_id), self.move_randomly(game)
        #print " robot {} has {} enemy around".format(self.robot_id, len(self.enemy_around(game)))
        if self.move_randomly(game):
            return self.move_randomly(game)
        else:
            enemies_1 = self.enemy_around(game, 1)
            enemies_2 = self.enemy_around(game)
            if len(enemies_1) > 0:
                if self.hp <= 15: 
                    return ['suicide']
                #attack the weakest enemy
                weakest_enemy = self.find_weakest(enemies_1)
                return ['attack', weakest_enemy.location]
            elif len(enemies_2) > 0:
                #no enemy around, extend to 2nd radius
                weakest_enemy = self.find_weakest(enemies_2)
                if rg.wdist(self.location, weakest_enemy.location) == 2:
                    return ['attack', rg.toward(self.location, weakest_enemy.location)]
                else:
                    return ['move', rg.toward(self.location, weakest_enemy.location)]
                
            return ['guard']
        #else:
        #next_move = rg.toward(self.location, rg.CENTER_POINT)
        #if next_move in game.robots
        #else:
        #    return ['move', next_move]

        return ['guard']
开发者ID:sufendyc,项目名称:merobot,代码行数:34,代码来源:one.py


示例12: act

    def act(self, game):

        # wyznaczamy zbiory różnych pól na planszy
        wszystkie = {(x, y) for x in xrange(19) for y in xrange(19)}
        wejscia = {loc for loc in wszystkie if 'spawn' in rg.loc_types(loc)}
        zablokowane = {loc for loc in wszystkie if 'obstacle' in rg.loc_types(loc)}
        druzyna = {loc for loc in game.robots if game.robots[loc].player_id == self.player_id}
        wrogowie = set(game.robots) - druzyna
        sasiednie = set(rg.locs_around(self.location)) - zablokowane
        sasiednie_wrogowie = sasiednie & wrogowie
        sasiednie_wrogowie2 = {loc for loc in sasiednie if (set(rg.locs_around(loc)) & wrogowie)} - druzyna

        ruch = ['move', rg.toward(self.location, rg.CENTER_POINT)]

        if self.location in wejscia:
            ruch = ['move',  rg.toward(self.location, rg.CENTER_POINT)]

        if self.location == rg.CENTER_POINT:
            ruch = ['guard']

        if sasiednie_wrogowie:
            if 9*len(sasiednie_wrogowie) < self.hp:
                ruch = ['attack', sasiednie_wrogowie.pop()]

        if sasiednie_wrogowie2:
            ruch = ['attack', sasiednie_wrogowie2.pop()]

        return ruch
开发者ID:astefaniuk,项目名称:linetc,代码行数:28,代码来源:robot07.py


示例13: act

    def act(self, game):

        def czy_wejscie(poz):
            if 'spawn' in rg.loc_types(poz):
                return True
            return False

        def czy_wrog(poz):
            if game.robots.get(poz) != None:
                if game.robots[poz].player_id != self.player_id:
                    return True
            return False
        
        # lista wrogów obok
        wrogowie_obok = []
        for poz in rg.locs_around(self.location):
            if czy_wrog(poz):
                wrogowie_obok.append(poz)

        # jeżeli jesteś w punkcie wejścia, opuść go
        if czy_wejscie(self.location):
            return ['move', rg.toward(self.location, rg.CENTER_POINT)]

        # jeżeli obok są przeciwnicy, atakuj
        if len(wrogowie_obok):
            return ['attack', wrogowie_obok.pop()]

        # jeżeli jesteś w środku, broń się
        if self.location == rg.CENTER_POINT:
            return ['guard']

        # idź do środka planszy
        return ['move', rg.toward(self.location, rg.CENTER_POINT)]
开发者ID:EdwardBetts,项目名称:python101,代码行数:33,代码来源:rgkod05a.py


示例14: act

 def act(self, game):
     # first run: make the 'updated' attribute
     if not hasattr(self, 'groups_updated'):
         self.groups_updated = -1
         self.ally_groups = []
         self.enemy_groups = []
         self.taget_group = None
         self.target_location = rg.CENTER_POINT
         self.bfs_grid = []
     # 'self' is an entity shared by all bots. each frame, only one bot needs to make decisions, then they are shared
     if self.groups_updated < game['turn']:
         self.groups_updated = game['turn']
         self.ally_groups, self.enemy_groups = self.compute_groups(game, True)
         # sort groups by strength (sum of health)
         self.enemy_groups = sorted(self.enemy_groups, key=(lambda grp: sum([game['robots'][loc].hp for loc in grp])))
         # attack weakest group
         # TODO multiple targets
         self.target_group = self.enemy_groups[0]
         target_location_x = sum([loc[0] for loc in self.target_group])
         target_location_y = sum([loc[1] for loc in self.target_group])
         self.target_location = (target_location_x, target_location_y)
         self.bfs_grid = bfs_tree(game['robots'], self.target_location, self.player_id)
     # bot-specifics: move towards target or attack if there
     next = self.bfs_grid[self.location[0]][self.location[1]]
     # print self.location, "to", self.target_location, "via", next
     if next is not None:
         if next in game['robots']:
             return self.guard_or_attack(game)
         else:
             return ['move', next]
     elif rg.toward(self.location, self.target_location) in game['robots']:
         return ['attack', rg.toward(self.location, self.target_location)]
     else:
         return self.guard_or_attack(game)
开发者ID:wrongu,项目名称:robotgame,代码行数:34,代码来源:pursuitbot.py


示例15: act

    def act(self, game):
        
        myId = self.robot_id
        myAge = 0

        if myId in self.age:
            self.age[myId] += 1
            myAge = self.age[myId]
        else:
            self.age[myId] = 0
       
        # get off the spawn point fast
        if myAge <= 3:
            return ['move', rg.toward(self.location, rg.CENTER_POINT)]
        
        # if there are enemies around, attack them
        for loc, bot in game.robots.iteritems():
            if bot.player_id != self.player_id:
                if rg.dist(loc, self.location) <= 1:
                    return ['attack', loc]

                # if we're in the center, stay put
        if self.location == rg.CENTER_POINT:
            return ['guard']

        # move toward the center slowly
        if game.turn % 2:
            return ['move', rg.toward(self.location, rg.CENTER_POINT)]
        
        return['guard']
开发者ID:jwygralak67,项目名称:robots,代码行数:30,代码来源:darbot001.py


示例16: act

    def act(self, game):
        if "spawn" in rg.loc_types(self.location):
            s = sanitize(['move', rg.toward(self.location, rg.CENTER_POINT)])
            return s

        adjacent_enemies = []
        for loc, bot in game.get('robots').items():
            if bot.get('player_id') != self.player_id:
                if rg.dist(loc, self.location) <= 1:
                    allies = 0
                    #Find out how many allies are around this enemy
                    for nloc, nbot in game.get('robots').items():
                        if bot.get("player_id") == self.player_id and rg.dist(loc, nloc) <=1:
                            allies = allies + 1
                    adjacent_enemies.append([loc, bot, allies])
            else:
                if "spawn" in rg.loc_types(bot.get("location")): #The friendly wants to get out of spawn, make way for it
                    r = Robot.move(self, game)
                    if r and rg.toward(bot.get("location"), rg.CENTER_POINT) == r[1]:
                            return sanitize(['move', rg.toward(self.location, rg.CENTER_POINT)])
        if adjacent_enemies and self.hp >= CRITICAL_HP:
            if len(adjacent_enemies) * ATTACK_DAMAGE > self.hp: # They can kill me! lets flee!
                return sanitize(self.flee(game))
            adjacent_enemies.sort(key= lambda x: (x[2], x[1].get("hp")))
            return sanitize(['attack', adjacent_enemies[0][0]])
        elif adjacent_enemies and self.hp < CRITICAL_HP:
            return sanitize(self.flee(game))
        else:
            r = Robot.move(self, game)

            if not r:
                return ["guard"]
            
            #Check if allied damaged bots will move to our destination, and if so, let them
            move = True
            for loc, bot in game.get('robots').items():
                if bot.get("player_id") == self.player_id and not bot.location == self.location:
                    if rg.dist(loc, r[1]) <= 1:
                        if Robot.get_destination(bot, game) == r[1]: #our destination matches, let them come
                            if bot.get("hp") < CRITICAL_HP:
                                return ["guard"]
                            else: # Figure out who should be given highest movement priority (based on which one is furthest from middle, or who has lowest hp in tiebreaker)
                                prio = rg.dist(self.location, rg.CENTER_POINT)
                                prio_o = rg.dist(bot.location, rg.CENTER_POINT)

                                if prio == prio_o: #Tie
                                    if self.hp >= bot.hp:
                                        move = True
                                    else:
                                        move = False
                                elif prio > prio_o:
                                    move = True
                                else:
                                    move = False
            if not move:
                return ["guard"]
            else:
                return sanitize(r) or ["guard"]
开发者ID:Lacra17,项目名称:robotgame-bots,代码行数:58,代码来源:Sunguard.py


示例17: act

    def act(self, game):
        # Update the class variables if this is a new turn. 
        if game.turn != self.currentTurn:
            # If this is the very first turn, print out some info.
            if game.turn == 1:
                print "The rally point is: {0}".format(self.rallyPoint);

            self.updateVariables(game);
            self.currentTurn = game.turn;
            print "New Turn! " + str(self.currentTurn) + " Friends: " + str(self.numberOfFriends) + " Foes: " + str(self.numberOfFoes);

        # First order of business, if this bot is on a spawn point, we need to get him out of there. 
        if 'spawn' in rg.loc_types(self.location):
            # Try to move toward the rally point.
            moveToPoint = rg.toward(self.location, self.rallyPoint);
            if 'normal' in rg.loc_types(moveToPoint):
                return ['move', moveToPoint];
            else:
                # Can't move towards the rally point. See where we can move. 
                adjacentLocations = rg.locs_around(self.location);
                for loc in adjacentLocations:
                    if 'normal' in rg.loc_types(loc):
                        return ['move', loc];

                # If we got here, we can't move off the spawn point. Let's try to do some damage if we have a nearby enemy. 
                for loc in adjacentLocations:
                    if loc in game.robots:
                        if game.robots[loc].player_id != self.player_id:
                            return self.attackOrSuicide(loc, game.robots[loc]);

                # If we are here, nothing else we can do, but guard. We must be blocked by our guys. Hopefully they will get out of the way.
                return ['guard'];


        # Now some strategy. 
        if self.numberOfFoes > self.numberOfFriends:
            # We have less bots than the enemy. Let's play it safe until the numbers are back in our favor.
            
            # Head to the rally point if possible. Fight if someone gets in the way, but be passive otherwise. 
            if (self.location == self.rallyPoint):
                return ['guard'];

            moveToPoint = rg.toward(self.location, self.rallyPoint);
            if 'normal' in rg.loc_types(moveToPoint):
                return ['move', moveToPoint];
            else:
                # We can't move. Attack if we can.
                for loc in adjacentLocations:
                    if loc in game.robots:
                        if game.robots[loc].player_id != self.player_id:
                            return self.attackOrSuicide(loc, game.robots[loc]);

            # Guard if we can't move.                     
            return ['guard'];
        
        else:
            # We have the numbers advantage. Start hunting. 
            return ['guard'];
开发者ID:pneisen,项目名称:robot-game-experiments,代码行数:58,代码来源:scrubby04.py


示例18: act_kiter

    def act_kiter(self, game):
        if 'foe' in map(self.in_square, self.local_spaces()):
            return self.evade()
        for square in self.local_spaces():
            if self.square_is_threatened(square):
                return ['attack', rg.toward(self.location, square)]

        return ['move', rg.toward(self.location,
                                  random.choice(self.enemies(game)).location)]
开发者ID:hwayne,项目名称:robotfight,代码行数:9,代码来源:fancy_prancer.py


示例19: act

 def act(self, game):
     available = rg.locs_around(self.location, filter_out = ('invalid', 'obstacle'))
     for loc, bot in game.robots.iteritems():
         if bot.player_id != self.player:
             if rg.dist(loc, self.location) == 1:
                 return ['attack', loc]
             elif rg.dist(loc, self.location) <= 3:
                 return ['move', rg.toward(self.location, loc)]
             else:
                 return ['move', rg.toward(self.location, rg.CENTER_POINT)]
开发者ID:FrankSalad,项目名称:tdcreates,代码行数:10,代码来源:johno_testbot.py


示例20: plan_move

 def plan_move(self, game, new_loc):
     if new_loc == self.location and self.location == rg.CENTER_POINT:
         return ['guard']
     if new_loc == self.location:
         return ['move', rg.toward(self.location, rg.CENTER_POINT)]
     around_me = rg.loc_types(new_loc)
     if around_me == ['normal']:
         return ['move', rg.toward(self.location, new_loc)]
     else:
         return None
开发者ID:Lacra17,项目名称:robotgame-bots,代码行数:10,代码来源:terriblebot.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rg.wdist函数代码示例发布时间:2022-05-26
下一篇:
Python rg.locs_around函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap