code
stringlengths
3
6.57k
block.left(field_map)
block.right(field_map)
block.down(field_map)
QLearning(Game)
__init__(self)
super(QLearning, self)
__init__(sub_well, 1000)
range(base**(self.field_width-1)
range(7)
range(self.field_width)
range(4)
range(len(self.key)
dict(zip(self.key, self.V)
np.load('QL.npy')
item()
checkEvents(self)
pygame.event.get()
pygame.quit()
exit(0)
getBlock(self, block)
range(len(Blocks_color)
getReward(self)
range(self.field_width)
range(self.field_width)
for (x, y)
np.var(temp)
getAllActions(self, block)
range(len(block.layouts)
getAllPossibleLocation(self.field_width, self.field_map, block, block.layouts[direction])
findBottomPosition(self.field_map, block, x, block.layouts[direction])
dropBlock(self.field_height, self.field_map, x, y, block.layouts[direction])
actions.append((x, direction)
resetMap(self.field_width, self.field_height, self.field_map)
getBestActionWithGreedy(self, block)
self.getBlock(block)
getStateIndex(self.field_width, self.field_height, self.field_map)
self.getAllActions(block)
random.random()
max(actions_value, key=actions_value.get)
list(actions_value.keys()
random.randint(0, len(actions_value)
getBestAction(self, block)
self.getBlock(block)
getStateIndex(self.field_width, self.field_height, self.field_map)
self.getAllActions(block)
max(actions_value, key=actions_value.get)
train(self)
range(1, self.repeat_num+1)
self.initialize()
getStateIndex(self.field_width, self.field_height, self.field_map)
self.getBlock(self.block_factory.cur_block)
self.getBestActionWithGreedy(self.block_factory.cur_block)
getNewMap(self.block_factory.cur_block, cur_action, cur_action[1], self.field_map)
getStateIndex(self.field_width, self.field_height, self.field_map)
self.getBlock(self.block_factory.next_block)
self.getBestAction(self.block_factory.next_block)
self.getReward()
self.update()
print("Epoch:"+str(i)
str(self.repeat_num)
str(self.lines_num)
str(self.alpha)
record.append(self.lines_num)
np.save('QL.npy', {"V": self.V})
np.save('record_QL.npy', {"record": record})
np.save('QL.npy', self.Q)
np.save('record_QL.npy', {"record": record})
QLGame(Game)
__init__(self)
super(QLGame, self)
__init__(10, 20)
np.load('QL.npy', allow_pickle=True)
item()
checkEvents(self)
pygame.event.get()
pygame.quit()
exit(0)
getBlock(self, block)
range(len(Blocks_color)
cutFieldMap(self, position)
range(self.field_height)
range(self.field_height)
range(sub_well)
getAllActions(self, field_width, field_height, block, field_map, init_pos)
range(len(block.layouts)
getAllPossibleLocation(field_width, field_map, block, block.layouts[direction])
findBottomPosition(field_map, block, x, block.layouts[direction])
dropBlock(field_height, field_map, x, y, block.layouts[direction])
self.getBlock(block)
getStateIndex(field_width, field_height, field_map)
resetMap(field_width, field_height, field_map)
getBestAction(self)
Block(self.block_factory.cur_block.screen, sub_well, self.field_height, self.block_factory.cur_block.layouts, self.block_factory.cur_block.direction, self.block_factory.cur_block.color, (0, -4)
range(self.field_width - sub_well + 1)
self.getAllActions(sub_well, self.field_height, cur_block, self.cutFieldMap(x)
loc_actions.items()
append(v)
actions.items()
max(v)
max(actions, key=actions.get)