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


Python Brain.activateInput方法代码示例

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


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

示例1: Scarab

# 需要导入模块: from brain import Brain [as 别名]
# 或者: from brain.Brain import activateInput [as 别名]
class Scarab(Body):
	def __init__(self,canvas,pos):
		#global icon
		super(Scarab,self).__init__(canvas,pos)
		self.name = "Scarab"
		#self.gl_shape = Rectangle(size=(self.size, self.size), source='./icons/'+icon)
		Legs( self )
		Mounth( self )
		TouchSense( self )
		
		#try:
		#	self.brain = pickle.load(open("./last_brain","r+"))
		#except Exception:
		self.brain = Brain( 6, 5, 1, 1, 2)
			#self.brain.teach( int(b'100000',2), int(b'001111',2), int(b'10000',2) )

		
	def __del__(self):
		print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>saving brain")
		#pickle.dump(self.brain,open("./last_brain","w"))
	
	def clock(self,modeler):
		self.name = "asd"
		super(Scarab,self).clock(modeler)
		inputs = (self.touch_sense.touch_state | (self.mounth.sense_status << 4)) & int(b'111111',2)
		outs = self.brain.activateInput( inputs )
		chkwalk = (outs&1) + (outs&2)>>1 + (outs&4)>>2 + (outs&8)>>3
		if chkwalk <= 1:
			if outs&1:
				self.walk_right()
			if outs&2:
				self.walk_up()
			if outs&4:
				self.walk_left()
			if outs&8:
				self.walk_down()
		if outs&16:
			#print(">>>>>>>>>>>>>>>>>>>>>>>>>>>EAT<<<<<<<<<<<<<<<<<<<<<<<<<<<")
			self.eat()
		
		lbli = bin(inputs)
		lbli = lbli.zfill(6)
		
		lblo = bin(outs)
		lblo = lblo.zfill(5)
		self.name = "in: " + lbli + "\nout:" + lblo# + "\n" + self.info_lbl.text
		self.info_lbl.text = self.name + '\nx: ' + str(self.pos_x) + '\ny: ' + str(self.pos_y) + '\npower: ' + str(self.power)
				
	def is_acid(self):
		return True
开发者ID:dddomodossola,项目名称:pyBrain,代码行数:52,代码来源:scarab.py

示例2: ScarabBob

# 需要导入模块: from brain import Brain [as 别名]
# 或者: from brain.Brain import activateInput [as 别名]
class ScarabBob(Body):
	def __init__(self,canvas,pos):
		global icon
		super(ScarabBob,self).__init__(canvas,pos)
		self.name = "ScarabBob"
		self.gl_shape.source='./icons/'+icon
		Legs( self )
		Mounth( self )
		TouchSense( self )
		
		try:
			self.brain = pickle.load(open("./last_brain","r+"))
			#self.brain.teach( int(b'010000',2), int(b'001111',2), int(b'10000',2), -50000000.0 )	#do not eat when is acid
		except Exception:
			self.brain = Brain( 6, 5, 1, 1, 0)
			self.brain.teach( int(b'100000',2), int(b'001111',2), int(b'10000',2), 100000.0 )	#when is sweet eat
			"""self.brain.teach( int(b'000001',2), int(b'110000',2), int(b'00001',2), 1000.0 )		#move to what you are touching
			self.brain.teach( int(b'000010',2), int(b'110000',2), int(b'00010',2), 1000.0 )
			self.brain.teach( int(b'000100',2), int(b'110000',2), int(b'00100',2), 1000.0 )
			self.brain.teach( int(b'001000',2), int(b'110000',2), int(b'01000',2), 1000.0 )
			self.brain.teach( int(b'001001',2), int(b'110000',2), int(b'00001',2), 1000.0 )
			self.brain.teach( int(b'000101',2), int(b'110000',2), int(b'00001',2), 1000.0 )
			self.brain.teach( int(b'000011',2), int(b'110000',2), int(b'00001',2), 1000.0 )
			self.brain.teach( int(b'000110',2), int(b'110000',2), int(b'00010',2), 1000.0 )
			self.brain.teach( int(b'001010',2), int(b'110000',2), int(b'00010',2), 1000.0 )
			self.brain.teach( int(b'001100',2), int(b'110000',2), int(b'00100',2), 1000.0 )
			self.brain.teach( int(b'000110',2), int(b'110000',2), int(b'00100',2), 1000.0 )
			self.brain.teach( int(b'010000',2), int(b'001111',2), int(b'10000',2), -500000.0 )	#do not eat when is acid
			self.brain.teach( int(b'010000',2), int(b'001110',2), int(b'00001',2), 1000.0 )	#walk away when acid
			self.brain.teach( int(b'010000',2), int(b'001101',2), int(b'00010',2), 1000.0 )	#walk away when acid
			self.brain.teach( int(b'010000',2), int(b'001011',2), int(b'00100',2), 1000.0 )	#walk away when acid
			self.brain.teach( int(b'010000',2), int(b'000111',2), int(b'01000',2), 1000.0 )	#walk away when acid
			self.brain.teach( int(b'000001',2), int(b'111110',2), int(b'00001',2), 500.0 )
			self.brain.teach( int(b'000010',2), int(b'111101',2), int(b'00010',2), 500.0 )
			self.brain.teach( int(b'000100',2), int(b'111011',2), int(b'00100',2), 500.0 )
			self.brain.teach( int(b'001000',2), int(b'110111',2), int(b'01000',2), 500.0 )"""

		
	def __del__(self):
		print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>saving brain")
		pickle.dump(self.brain,open("./last_brain","w"))
	
	def clock(self,modeler):
		super(ScarabBob,self).clock(modeler)
		inputs = (self.touch_sense.touch_state + (self.mounth.sense_status << 4)) & int(b'111111',2)
		outs = self.brain.activateInput( inputs )
		chkwalk = (outs&1) + (outs&2)>>1 + (outs&4)>>2 + (outs&8)>>3
		if chkwalk <= 1:
			if outs&1:
				self.walk_right()
			if outs&2:
				self.walk_up()
			if outs&4:
				self.walk_left()
			if outs&8:
				self.walk_down()
		if outs&16:
			#print(">>>>>>>>>>>>>>>>>>>>>>>>>>>EAT<<<<<<<<<<<<<<<<<<<<<<<<<<<")
			self.eat()
		
		lbli = bin(inputs)
		lbli = lbli.zfill(6)
		
		lblo = bin(outs)
		lblo = lblo.zfill(5)
		self.name = "in: " + lbli + "\nout:" + lblo# + "\n" + self.info_lbl.text
		self.info_lbl.text = self.name + '\nx: ' + str(self.pos_x) + '\ny: ' + str(self.pos_y) + '\npower: ' + str(self.power)
		
				
	def is_acid(self):
		return True
开发者ID:dddomodossola,项目名称:pyBrain,代码行数:73,代码来源:scarabBob.py


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