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


Python cell.Cell类代码示例

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


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

示例1: Gol02Test

class Gol02Test(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def testCellCreated(self):
        self.cell = Cell()
        assert self.cell.exist() == True, 'Cell was not created'

    def testCellAddNeighbour(self):
        self.cell = Cell()
        self.cell2 = Cell()
        assert self.cell.add(self.cell2) == self.cell2, 'Cell has no neighbour'

    def testCellNumberOfNeighbours(self):
        self.cell = Cell()
        print self.cell.number_of_neighbours()
        assert self.cell.number_of_neighbours() == 0, 'Cell does not know about its neighbours'

    def testCellNumberOfNeighbours2(self):
        self.cell = Cell()
        self.cell2 = Cell()
        self.cell.add(self.cell2)
        print self.cell.number_of_neighbours()
        assert self.cell.number_of_neighbours() == 1, 'Cell does not know about its neighbours'
开发者ID:hemmerling,项目名称:codingdojo,代码行数:28,代码来源:gol02_test.py

示例2: explore_action

    def explore_action(self):
        for neighbor in self.current_cell.get_neighbors():
            row,col = neighbor.row, neighbor.col

            if self.cells[row][col] is None:
                dir_to = Cell.direction_to(self.current_cell, neighbor)
                if dir_to is not None:
                    return Move(dir_to)

        oldest_cell = None
        oldest_time = 0
        for row, i in zip(self.cells, range(len(self.cells))):
            for cell, j in zip(row, range(len(row))):
                if cell is None:
                    dir_to = Cell.direction_to(self.current_cell, self.world.cells[i][j])
                    if dir_to is not None:
                        return Move(dir_to)
                else:
                    cell.step_time
                    if cell.step_time > oldest_time:
                        oldest_time = cell.step_time
                        oldest_cell = cell

        if oldest_cell is not None:
            dir_to = Cell.direction_to(self.current_cell, oldest_cell)
            if dir_to is not None:
                return Move(dir_to)

        return Move(Direction.random_direction())
开发者ID:cnoziere,项目名称:DynamicWorld,代码行数:29,代码来源:animal.py

示例3: __init__

 def __init__(self, level, pos):
     Cell.__init__(self, level, pos)
     
     self.tile = 2, 0
     self.player_can_enter = False
     self.robot_can_enter = True
     
开发者ID:saltire,项目名称:roverchip,代码行数:6,代码来源:fire.py

示例4: __init__

    def __init__(self):
        app = QApplication(sys.argv)
        QObject.__init__(self)
        super(Gui, self).__init__()
        self.app = app
        self.setupUi(self)
        self.gridLayoutWidget.setStyleSheet("background-color: "
                                            "rgb(117,117,117);")
        self.cell_matrix = [[None for y in range(9)]
                            for x in range(9)]

        for f_x in range(3):
            for f_y in range(3):
                frame = QtWidgets.QFrame(self.gridLayoutWidget)
                widget = QtWidgets.QWidget(frame)
                widget.setStyleSheet("background-color: rgb(170,170,170);")
                # widget.setGeometry(QRect(160, 170, 160, 80))
                gridLayout = QtWidgets.QGridLayout(widget)

                gridLayout.setContentsMargins(0, 0, 0, 0)
                for x in range(3):
                    for y in range(3):
                        cell = Cell(self)
                        self.cell_matrix[(f_x*3)+x][(f_y*3)+y] = cell
                        cell.setStyleSheet("QLabel{background-color: white;}")
                        gridLayout.addWidget(cell, y, x)
                self.grid.addWidget(frame, f_y, f_x)

        self.show()
开发者ID:Vampouille,项目名称:pySudoku,代码行数:29,代码来源:gui.py

示例5: testCellCanDetectWheatherAnotherCellIsNeighboured

 def testCellCanDetectWheatherAnotherCellIsNeighboured():
     cellA = Cell(True, [2,2])
     cellB = Cell(True, [3,2])
     cellC = Cell(True, [4,3])
     assert cellA.is_neighboured_to(cellB) == True, 'A Cell has not detected another cell correctly as neighbour'
     assert cellB.is_neighboured_to(cellC) == True
     assert cellA.is_neighboured_to(cellC) == False
开发者ID:hemmerling,项目名称:codingdojo,代码行数:7,代码来源:gol01_test.py

示例6: setUp

 def setUp(self):
     self.grid = Grid()
     for row in range(1,10):
         for column in range(1,10):
             cell = Cell(row,column)
             cell.setValues([row,column])
             self.grid.setCell(row, column, cell)
开发者ID:Tim-Barton,项目名称:SudokuSolver,代码行数:7,代码来源:grid_test.py

示例7: CellTest

class CellTest(unittest.TestCase):

    
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def testCoordinateCreated(self):
        self.coordinate = Coordinate()
        assert self.coordinate.set(1,2) == (1,2), 'Coordinate was created'
        assert self.coordinate.coordX == 1, 'Coordinate was created'
        assert self.coordinate.coordY == 2, 'Coordinate was created'

    def testCellCreated(self):
        coordinate = Coordinate(1,1)
        self.cell = Cell(coordinate)
        assert self.cell.exists() == False, 'Cell was not created'

    def testCellSetValue(self):
        coordinate = Coordinate(1,1)
        self.cell = Cell(coordinate)
        self.cell.setValue(True)
        assert self.cell.value == True, 'Cell has invalid value'

    def testGetNeigbours(self):
        myNeighbourListe = [(0,0), (0,1), (0,2), (1,0), (1,2), (2,0), (2,1), (2,2)]
        coordinate = Coordinate(1,1)
        self.cell = Cell(coordinate)
        generatedNeigbhourListe = self.cell.getNeighbours()
        assert generatedNeigbhourListe == myNeighbourListe, 'Cell has invalid value'
开发者ID:hemmerling,项目名称:codingdojo,代码行数:32,代码来源:cell_test.py

示例8: draw

 def draw(self):
     if self.update_request:
         self.update_request = False
         self.request_update_body()
         self.clear_io_cache()
         
     Cell.draw(self)
开发者ID:fhorinek,项目名称:pi8bit,代码行数:7,代码来源:module.py

示例9: __init__

 def __init__(self, parent):
     Cell.__init__(self, parent)
     Controller.__init__(self, self.parent.canvas, parent)
     self.offset_x = 0
     self.offset_y = 0
     self.update_request = False
     self.old_zoom = False
开发者ID:fhorinek,项目名称:pi8bit,代码行数:7,代码来源:module.py

示例10: draw_io

    def draw_io(self):
        Cell.draw_io(self)
        
        if not self.drawable:
            return

        for k in self.objects:
            self.objects[k].draw_io()
开发者ID:fhorinek,项目名称:pi8bit,代码行数:8,代码来源:module.py

示例11: testSetCellGetCell

 def testSetCellGetCell(self):
     testCell = Cell(1,1)
     testCell.setValues([1])
     currentCell = self.grid.getCell(1,1)
     self.assertNotEqual(testCell, currentCell, "Incorrect setup, currentCell should not match")
     self.grid.setCell(1, 1, testCell)
     newCell = self.grid.getCell(1, 1)
     self.assertEqual(testCell, newCell, "Cells do not match")
开发者ID:Tim-Barton,项目名称:SudokuSolver,代码行数:8,代码来源:grid_test.py

示例12: __init__

    def __init__(self, level, pos, flow_dir=None):
        Cell.__init__(self, level, pos)
        
        self.tile = (3, 0) if flow_dir is None else (4, 0)
        self.rotate = 0 if flow_dir is None else flow_dir
        self.player_can_enter = False
        self.robot_can_enter = False

        self.flow_dir = flow_dir
开发者ID:saltire,项目名称:roverchip,代码行数:9,代码来源:water.py

示例13: _populate_cells

    def _populate_cells(self):
        """Create empty cells"""
        for row in range(0, self.rows):
	        self.cells.append([])
	        for column in range(0, self.columns):
	            cell = Cell()
	            cell.row = row
	            cell.col = column
	            self.cells[row].append(cell)
开发者ID:eslammostafa,项目名称:minesweeper,代码行数:9,代码来源:cells_map.py

示例14: update

    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])
开发者ID:tucif,项目名称:BiokteriID3,代码行数:57,代码来源:main.py

示例15: __init__

 def __init__(self, level, pos, facing):
     Cell.__init__(self, level, pos)
     
     self.tile = 7, 3 + (facing % 2)
     self.player_can_enter = False
     self.robot_can_enter = False
     self.object_can_enter = False
     
     self.floor_tile = 0, 0
开发者ID:saltire,项目名称:roverchip,代码行数:9,代码来源:chipdoor.py


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