本文整理汇总了Python中cell.Cell.type方法的典型用法代码示例。如果您正苦于以下问题:Python Cell.type方法的具体用法?Python Cell.type怎么用?Python Cell.type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cell.Cell
的用法示例。
在下文中一共展示了Cell.type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from cell import Cell [as 别名]
# 或者: from cell.Cell import type [as 别名]
def update(self):
self.queue_draw()
cellsToPop=[]
for cell in self.cells:
cell.update(self.currentState)
if cell.type=="NormalCell":
if cell.posX+cell.width<0 or (cell.status=="Dead" and len(cell.dyingParticles)<=0):
cellsToPop.append(cell)
for cell in cellsToPop:
self.cells.pop(indexOf(self.cells,cell))
if cell==self.virus[0].targetCell:
self.virus[0].targetCell=None
if self.currentState=="Running":
self.ticksToNextCell-=1
if self.ticksToNextCell<=0:
self.ticksToNextCell=random.randint(self.minTimeToNextCell,self.maxTimeToNextCell)
newCell=Cell(WINDOW_SIZE,
random.randint(0,TRAINING_ZONE_LIMIT-CELL_HEIGHT))
newCell.velX=-random.random()*2
newCell.type="NormalCell"
self.cells.append(newCell)
#update virus
for virus in self.virus:
if not virus.isDead:
virus.update(self.currentState)
if len(self.cells)>0 and virus.targetCell==None:
virus.targetCell=self.cells[len(self.cells)-1]
#This is a temprorary decision function
#Actual classification should do this
self.classify_cell(widget=None)
if virus.is_colliding_with(virus.targetCell):
if not virus.targetCell.status:
if virus.status=="Attacking":
virus.targetCell.status="Dying"
if virus.status=="Eating":
virus.targetCell.status="BeingEaten"
if virus.targetCell.status=="Dead":
virus.targetCell=None
for (cell,type) in self.trainingSet:
for i in xrange(len(self.classificationList)):
if type==self.classificationList[i]:
rightLimit=self.divisionPoints[i]
if i==0:
leftLimit=0
else:
leftLimit=self.divisionPoints[i-1]
break
cell.update(self.currentState,[leftLimit,rightLimit-cell.width,TRAINING_ZONE_LIMIT,WINDOW_SIZE-cell.height])
示例2: update
# 需要导入模块: from cell import Cell [as 别名]
# 或者: from cell.Cell import type [as 别名]
def update(self):
self.queue_draw()
cellsToPop=[]
for cell in self.cells:
cell.update(self.currentState)
if cell.posX+cell.width<0 or cell.isDead==True:
cellsToPop.append(cell)
for cell in cellsToPop:
self.cells.pop(indexOf(self.cells,cell))
for virus in self.virus:
if cell==virus.targetCell:
virus.targetCell=None
break
if self.currentState=="Running":
if self.ticksToNextCell<=0:
if len(self.cells)<MAX_CELLS:
self.ticksToNextCell=random.randint(self.minTimeToNextCell,self.maxTimeToNextCell)
newCell=Cell(WINDOW_SIZE,
random.randint(0,TRAINING_ZONE_LIMIT-CELL_HEIGHT))
newCell.velX=-(random.random()+3)
newCell.type="NormalCell"
self.cells.append(newCell)
else:
self.ticksToNextCell-=1
#update virus
for virus in self.virus:
if not virus.isDead:
virus.update(self.currentState)
if len(self.cells)>0 and virus.targetCell==None and virus.status=="Waiting1":
for cell in self.cells:
if cell.isAvailable:
virus.targetCell=cell
cell.isAvailable=False
break
示例3: test_type
# 需要导入模块: from cell import Cell [as 别名]
# 或者: from cell.Cell import type [as 别名]
def test_type(self):
cell = Cell()
self.assertEqual(cell.type, '')
cell.type = 'tree'
self.assertEqual(cell.type, 'tree')
示例4: update
# 需要导入模块: from cell import Cell [as 别名]
# 或者: from cell.Cell import type [as 别名]
def update(self):
self.queue_draw()
cellsToPop=[]
for cell in self.cells:
cell.update(self.currentState)
if cell.type=="NormalCell":
if(cell.status=="Dead" and len(cell.dyingParticles)<=0):
cellsToPop.append(cell)
for cell in cellsToPop:
self.cells.pop(indexOf(self.cells,cell))
if cell==self.virus[0].targetCell:
self.virus[0].targetCell=None
if self.currentState=="Running":
if self.ticksToNextCell<=0:
if len(self.cells)< MAX_CELLS:#self.currentCell < self.numCells:
self.ticksToNextCell=random.randint(self.minTimeToNextCell,self.maxTimeToNextCell)
#print "NumCells", self.numCells
#print self.apareciendo
# print self.apareciendo[self.currentCell]
#print self.currentCell
newCell=Cell(WINDOW_SIZE - CELL_WIDTH*2,
random.randint(0,self.trainingZoneLimit-CELL_HEIGHT), 0,0,"TrainCell", self.apareciendo[self.currentCell])
newCell.velX=-random.random()*2
newCell.type="NormalCell"
self.cells.append(newCell)
self.currentCell=(self.currentCell+1)%self.numCells
else:
self.ticksToNextCell-=1
#update virus
for virus in self.virus:
if not virus.isDead:
virus.update(self.currentState)
if len(self.cells)>0 and virus.targetCell==None:
#virus.targetCell=self.cells[len(self.cells)-1]
for i in xrange(len(self.cells)):
idx = random.randint(0,len(self.cells)-1)
if self.cells[idx].hp > 0:
virus.targetCell = self.cells[idx]
break
if virus.targetCell:
current_state = self.qagent.update(virus.targetCell)
print "Current Action: ",
if current_state == "A":
virus.status="Attacking"
if current_state =="C":
virus.status="Eating"
if current_state =="D":
virus.status="Defending"
virus.targetCell.status = "defended"
if current_state =="X":
virus.isDead = True
print virus.status
print '-'*20
#virus.status="Defending"
#virus.targetCell.status = "defended"
#Hacer accion random
#aqui clasifica###################################################################
if virus.is_colliding_with(virus.targetCell):
if not virus.targetCell.status:
if virus.status=="Attacking":
virus.targetCell.status="Dying"
if virus.status=="Eating":
virus.targetCell.status="BeingEaten"
if virus.targetCell.status=="Dead":
virus.targetCell=None
leftLimit=0
rightLimit=0
for (cell,type) in self.trainingSet:
for i in xrange(len(self.classificationList)):
if type==self.classificationList[i]:
rightLimit=self.divisionPoints[i]
if i==0:
leftLimit=0
else:
leftLimit=self.divisionPoints[i-1]
break
cell.update(self.currentState,[leftLimit,rightLimit-cell.width,600,WINDOW_SIZE-cell.height])