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


Python Board.placeMino方法代码示例

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


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

示例1: __init__

# 需要导入模块: import Board [as 别名]
# 或者: from Board import placeMino [as 别名]
class DummyController:
	board = None
	curMino = None
	linesCleared = None
	gameOver = None
	player = None
	streak = None

	def __init__(self, player):
		self.board = Board()
		self.curMino = choice(Tetrominoes.minoes)
		self.linesCleared = 0
		self.streak = 0
		self.player = player
		gameOver = False

	def tick(self):
		self.player.makeMove(self)

	def getMino(self):
		return Mino(self.curMino)

	def getBoard(self):
		return Board(self.board)

	def makeMove(self, move):
		mino = Mino(self.curMino)
		for i in range(move[1]):
			mino.rotate()

		newBoard = self.board.placeMino(mino, move[0])
		if newBoard:
			self.board = newBoard
		else:
			print "Controller: invalid move received"
			raise

		clearedLines = self.board.clearAndReturnLines()
		
		if clearedLines == 0:
			self.streak = 0
		else:
			self.streak += clearedLines

		self.linesCleared += clearedLines
		self.curMino = choice(Tetrominoes.minoes)

	def gameIsOver(self):
		self.gameOver = True

	def addLines(self, num):
		self.board.addLines(num)

	def draw(self):
		self.board.draw()
开发者ID:chaitub1,项目名称:python-tetrisai,代码行数:57,代码来源:DummyController.py

示例2: makeMove

# 需要导入模块: import Board [as 别名]
# 或者: from Board import placeMino [as 别名]
	def makeMove(self, move):
		print move
		b = Board(self.board)
		m = Mino(self.curMino)

		for i in range(move[1]):
			m.rotate()

		m.draw()
		b = b.placeMino(m, move[0])
		b.clearAndReturnLines()
		self.expb = b

		for i in range(move[1]):
			self.keyPress(126)

		pd = (move[0] - 3)
		if pd > 0:
			for i in range(pd):
				self.keyPress(124)
		else:
			for i in range(abs(pd)):
				self.keyPress(123)

		self.keyPress(49)
		sleep(lcWait)
		self.readScreen()


		for i in range(20):
			for j in range(10):
				if self.expb.board[i][j] != self.board.board[i][j]:
					print "Ops!"
					self.expb.draw()
					self.board.draw()
					print "---"
					break
开发者ID:chaitub1,项目名称:python-tetrisai,代码行数:39,代码来源:TetrisBattleController.py


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