本文整理汇总了Python中Grid.Grid类的典型用法代码示例。如果您正苦于以下问题:Python Grid类的具体用法?Python Grid怎么用?Python Grid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Grid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadReferenceImage
def loadReferenceImage(self, path = ''):
ref_grid = Grid()
#if self.grid.ext_color:
#self.ref_name = 'ext_'+self.ref_name
ref_grid.image2Grid(path+self.ref_name, ext_colors=self.grid.ext_color)
ref_grid.visualize()
return ref_grid
示例2: test_get_value
def test_get_value():
g_1 = Grid(3,3)
assert g_1.get_value(2,2) == 0
g_1.array[2][2] = 3
assert g_1.get_value(2,2) == 3
assert g_1.get_value(10, 10) == -1
assert g_1.get_value(-5, -3) == -1
示例3: __init__
def __init__(self, points=(), left=0.0, right=1.0,
start=0.0, end=1.0,
id=u'', classes=(),
lineidprefix=u'', lineclasses=()):
"""
@param points: A sequence of points to draw grid lines at
@param left: The leftmost coordinate to begin drawing grid lines at
@param right: The rightmost coordinate to stop drawing grid lines at
@param start: The starting coordinate of the axis
@param end: The ending coordinate of the axis
@param id: The unique ID to be used in the SVG document
@type id: string
@param classes: Classnames to be used in the SVG document
@type classes: string or sequence of strings
@param lineidprefix: The prefix for each grid line's ID
@type lineidprefix: string
@param lineclasses: Classnames to be applied to each grid line
@type lineclasses: string or sequence of strings
"""
Grid.__init__(self, points, start, end, id, classes, lineidprefix, lineclasses)
self.left = left
self.right = right
示例4: __init__
def __init__(self, data, param):
Grid.__init__(self, data, param)
self.param.m = self.param.partitionsHTree[1]
self.param.maxHeightHTree = 2
logging.debug("Grid_pure: size: %d" % self.param.m)
示例5: __init__
class GridManager:
# Constructor
def __init__(self):
self.__grid = Grid()
self.__gamePlayer = GamePlayer()
self.__userPlayer = UserPlayer()
# Start Game
def startGame(self):
# Will continue toggling between
# Game and User turns until the
# Grid is Full (which is a loss)
# or a 2048 tile is encountered
# (which is a win)
while (not self.__grid.gridContains(2048)):
self.__gamePlayer.makeMove(self.__grid)
self.__grid.printGrid()
if (not self.__userPlayer.makeMove(self.__grid)):
print "User Lost!"
break
if (self.__grid.gridContains(2048)):
print "User Won!"
示例6: __init__
def __init__(self, data, param):
Grid.__init__(self, data, param)
self.param.m = self.param.part_size
self.param.maxHeightHTree = 2
logging.debug("Grid_standard: size: %d" % self.param.m)
示例7: make_grid
def make_grid(self):
if not(self.Density): self.PCL.reset(); self.Density = Grid(self.shape, self.x0y0, self.cellsize, self.nodata)
if not(self.Intensity): self.PCL.reset(); self.Intensity = Grid(self.shape, self.x0y0, self.cellsize, self.nodata)
[[self.__converter__(xyz, mode="both") for xyz in XYZ] for XYZ in self.PCL.input.a()]
print "[Grid = Intensity / Density] ...";
self.Gridded = Grid(self.shape, self.x0y0, self.cellsize, self.nodata)
self.Gridded.Z = self.Intensity.Z / self.Density.Z
return self.Gridded
示例8: __init__
def __init__(self, width, height):
self.width = width
self.height = height
self.block = None
self.grid = Grid(width, height)
self.__add_borders(self.grid)
self.background = Grid(width, height)
self.grid.copy_content_into(self.background)
示例9: __init__
def __init__(self, raw_grid):
Grid.__init__(self, raw_grid)
# Inherits Grid class
self.number_of_iterations_yet = 0
self.gamma = 0.7
# gamma : discount factor
self.errant_probability = 0.1
# two errant outcomes
self.intended_probability = 0.8
示例10: getNewPuzzle
def getNewPuzzle():
global difficulty_setting
new_grid = Grid(db_read, difficulty_setting)
new_puzzle = new_grid.generate_puzzle()
clues = new_grid.clues
missing_letters = new_grid.missing_letters
#we return three things in the data - a new puzzle, a list of clues for that puzzle, and the missing letters to the answer of that puzzle
print missing_letters
return json.dumps({'puzzle': new_puzzle, 'clues': clues, 'answers' : missing_letters})
示例11: initializeGrid
def initializeGrid(self, M, n):
"""Grid initizialed by funtions startLevel and startState
Function takes the number of species M and dims of the
2-D lattice (n by n)"""
grid = Grid()
for i in range(n):
row = []
for j in range(n):
row.append(Cell(self,self.startLevel(M), self.startState()))
grid.append(row)
return grid
示例12: main
def main():
"""Manages the huddling simulation"""
sim = Simulate(60)
grid = Grid()
# Iterate board
iterations = 150
for i in range(0, iterations):
sim.step()
grid.update(sim.penguins)
# time.sleep(0.1)
sim.save("iter_" + str(i))
time.sleep(3)
示例13: __init__
def __init__(self,parent):
AbsolutePanel.__init__(self)
self.userGrid = Grid()
self.userGrid.createGrid(6, 6)
self.userGrid.addTableListener(self)
self.userGrid.setBorderWidth(2)
self.userGrid.setCellPadding(4)
self.userGrid.setCellSpacing(1)
self.userGrid.setColLabelValue(0,"Username")
self.userGrid.setColLabelValue(1,"First Name")
self.userGrid.setColLabelValue(2,"Last Name")
self.userGrid.setColLabelValue(3,"Email")
self.userGrid.setColLabelValue(4,"Department")
self.userGrid.setColLabelValue(5,"Password")
self.newBtn = Button("New")
self.deleteBtn = Button("Delete")
self.deleteBtn.setEnabled(False)
self.add(self.userGrid)
self.add(self.newBtn)
self.add(self.deleteBtn)
return
示例14: __init__
def __init__(self, window):
self.window = window
self.colours = {'white' : (255, 255, 255, 0), 'outerspace': (65, 74, 76, 0) }
pyglet.gl.glClearColor(*self.colours['outerspace'])
#Load images, create batch-groups, a batch
pyglet.resource.path = ['tiles']
pyglet.resource.reindex()
#self.explosion_stream = open('explosion2strip.png', 'rb')
#self.explosion = pyglet.image.load('explosion1strip.png')
self.hexWater = pyglet.resource.image('hex.png')
self.hexMud = pyglet.resource.image('hexDirt.png')
self.hexUnwalkable = pyglet.resource.image('hexUnwalkable.png')
self.ship = pyglet.resource.image('ship.png')
self.background = pyglet.graphics.OrderedGroup(0)
self.foreground = pyglet.graphics.OrderedGroup(1)
self.effectslayer = pyglet.graphics.OrderedGroup(2)
self.cellbatch = pyglet.graphics.Batch()
self.grid = Grid(12, 8)
self.hexView = HexView(self.grid, 64, 55, 17, 0, 0) #todo: something to get this centered in the screen automatically
self.screenCoordinates = self.hexView.screenCoordinates()
self.selectedCell = None
self.phase = 1
self.movingUnit = False #True if a unit is being moved
self.currentFaction = "Viper"
示例15: __init__
def __init__(self):
self.user_requested_exit = False
self.player_turn = 1
self.grid = Grid()
self.is_a_winner = False
print 'Welcome to TicTacToe!'
print 'Here is the grid'