本文整理汇总了Python中block.Block.clear方法的典型用法代码示例。如果您正苦于以下问题:Python Block.clear方法的具体用法?Python Block.clear怎么用?Python Block.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block.Block
的用法示例。
在下文中一共展示了Block.clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_block_list
# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import clear [as 别名]
def get_block_list(world):
blocks = {}
for obj in world.objects.values():
if obj.type.name != "BLOCK":
continue
block = None
if world.atom_true(worldsim.Atom(world.predicates["table"], [obj])):
block = Block(Block.TABLE, obj.name)
elif world.atom_true(worldsim.Atom(world.predicates["triangle"], [obj])):
block = Block(Block.TRIANGLE, obj.name)
elif world.atom_true(worldsim.Atom(world.predicates["block"], [obj])):
block = Block(Block.SQUARE, obj.name)
if not block:
continue
block.clear = False
block.on = None
block.onfire = False
if block.type == block.TABLE:
table = block
blocks[obj.name] = block
for atom in world.atoms:
if atom.predicate == world.predicates["on"]:
blocks[atom.args[0].name].on = blocks[atom.args[1].name]
elif atom.predicate == world.predicates["on-table"]:
blocks[atom.args[0].name].on = table
elif atom.predicate == world.predicates["clear"]:
blocks[atom.args[0].name].clear = True
elif atom.predicate == world.predicates["onfire"]:
blocks[atom.args[0].name].onfire = True
return sorted(blocks.values(), key = lambda x: x.id)