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


Python AI.update方法代码示例

本文整理汇总了Python中ai.AI.update方法的典型用法代码示例。如果您正苦于以下问题:Python AI.update方法的具体用法?Python AI.update怎么用?Python AI.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ai.AI的用法示例。


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

示例1: update

# 需要导入模块: from ai import AI [as 别名]
# 或者: from ai.AI import update [as 别名]
 def update(self, **kwargs):
     """ (**kwargs) -> None
     Updates the aggressive AI.
     Remember, the ball_x, ball_y, ball_vx (x speed), ball_vy
     (y speed), paddle_x, and paddle_y, MUST be supplied
     on every game iteration.
     """
     AI.update(self, **kwargs)
开发者ID:BrianMao04,项目名称:PlayMatrix,代码行数:10,代码来源:aggressiveAI.py

示例2: Client

# 需要导入模块: from ai import AI [as 别名]
# 或者: from ai.AI import update [as 别名]
class Client(object):
	def __init__(self):
		self.conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

	def connect(self, host, port):
		self.conn.connect((host, port))
		info = self.conn.recv(1024)
		row, col, player = info.split(" ")
		print "-------------Status------------"
		print "WORLD_ROWS : %s" %(row)
		print "WORLD_COLS : %s" %(col)
		print "PLAYER	  : %s" %(player)
		print "-------------------------------\n\n"
		print "Connected. Waiting..."
		if int(player) == 1: print "You are RED."
		else:               print "You are BLUE."

		self.ai = AI(int(row), int(col), int(player))
		self.conn.send(self.ai.name+"\n")
		
		data = self.conn.recv(1024)
		print "Teamname:", self.ai.name
		print "Opponent:", data.strip()
		
	def play(self, viewflag=False) :
		if viewflag == True:
			gamescene = Gamescene(self.ai)
		while True:
			recvdata = self.conn.recv(4096)
			if recvdata in ["WIN\n", "DRAW\n", "LOSE\n"]: 
				print "Result:", recvdata				
				break
			recvdata = recvdata.strip().split(" ")
			self.ai.update(recvdata[1])
			print "*" * 20
			print "ai.map update : "
			print self.ai.map
			print "*" * 20
			response = self.ai.think()
			self.conn.send(response)
			if viewflag:
				gamescene.update()
			gc.collect()

	def close(self):
		self.conn.close()
开发者ID:YunseokJANG,项目名称:Chain4,代码行数:48,代码来源:client.py

示例3: __init__

# 需要导入模块: from ai import AI [as 别名]
# 或者: from ai.AI import update [as 别名]
class Creature:
    def __init__(self, game, breed):
        self.game = game
        self.breed = breed
        self.health = breed.max_health
        self.fov = FOV(self.game,self)
        self.ai = AI(self.game,self)
        self.status_effects = []
        self.energy = 0

    @property
    def name(self):
        if self.alive:
            return self.breed.name
        else:
            return "%s Corpse"%self.breed.name
    @property
    def char(self):
        if self.alive:
            return self.breed.char
        else:
            return CORPSE_CHAR
    @property
    def color(self):
        if self.alive:
            return self.breed.color
        else:
            return self.majority_material.color

    @property
    def health_mod(self):
        return sum([se.health_mod for se in self.status_effects])
    @property
    def agility_mod(self):
        return sum([se.agility_mod for se in self.status_effects])
    @property
    def armor_mod(self):
        return sum([se.armor_mod for se in self.status_effects])
    @property
    def perception_mod(self):
        return sum([se.perception_mod for se in self.status_effects])
    @property
    def size_mod(self):
        return sum([se.size_mod for se in self.status_effects])
    @property
    def strength_mod(self):
        return sum([se.strength_mod for se in self.status_effects])
    @property
    def accuracy_mod(self):
        return sum([se.accuracy_mod for se in self.status_effects])
    @property
    def defense_mod(self):
        return sum([se.defense_mod for se in self.status_effects])
    @property
    def sound_mod(self):
        return sum([se.sound_mod for se in self.status_effects])
    @property
    def damage_mod(self):
        return sum([se.damage_mod for se in self.status_effects])
    @property
    def speed_mod(self):
        return sum([se.speed_mod for se in self.status_effects])

    @property
    def max_health(self): return self.breed.max_health + self.health_mod
    @property
    def agility(self): return self.breed.agility + self.agility_mod
    @property
    def armor(self): return self.breed.armor + self.armor_mod
    @property
    def perception(self): return self.breed.perception + self.perception_mod
    @property
    def size(self): return self.breed.size + self.size_mod
    @property
    def strength(self): return self.breed.strength + self.strength_mod

    @property
    def materials(self): return self.breed.materials
    @property
    def majority_material(self):
        return sorted(self.materials,key=lambda m: self.materials[m])[-1]

    @property
    def death_func(self):
        return self.breed.death_func
    @property
    def abilities(self):
        return self.breed.abilities

    @property
    def speed(self):
        return self.breed.speed + self.speed_mod

    def update(self):
        if self.energy >= ENERGY_THRESHOLD:
            self.energy -= ENERGY_THRESHOLD
            
            #TODO status effect durations with new energy system
            se_to_remove = []
            for se in self.status_effects:
#.........这里部分代码省略.........
开发者ID:mscottmoore16,项目名称:golemrl,代码行数:103,代码来源:creature.py


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