本文整理汇总了Python中cube.Cube.finish方法的典型用法代码示例。如果您正苦于以下问题:Python Cube.finish方法的具体用法?Python Cube.finish怎么用?Python Cube.finish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cube.Cube
的用法示例。
在下文中一共展示了Cube.finish方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Environment
# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import finish [as 别名]
class Environment(object):
# Initialize a random cube
def __init__(self, N):
self.N = N
self.cube = Cube(N=N)
def suffle(self, rand_nb=None, fixed_action=None):
if rand_nb is not None:
moves = self.cube.randomize(rand_nb)
return moves
self.perform_action(fixed_action)
return fixed_action
# Make a move and get a reward:
# 0 is the cube is not finish
# 1 is the cube is done
def perform_action(self, action):
[f, l, d] = action
self.cube.move(f, l, d)
return self.reward()
def reward(self,):
return self.cube.finish()
# if self.cube.finish():
# return 1.
# for i in range(6):
# if np.array_equal(self.cube.stickers[i, :, :], i * np.ones((self.N, self.N))):
# return 0.1
# return 0.
# Select a random_action
def random_action(self,):
f = np.random.randint(6)
l = np.random.randint(self.N)
d = 1 + np.random.randint(3)
return [f, l, d]
def get_state(self,):
return self.cube.stickers