def _valid_actions(self): valid_actions = [] for act in Action.__members__.values(): lines = self._get_lines(action=act.get_value()) if self._game_board.movable(lines=lines, to_left=Action.left_direction( act.get_value())): valid_actions.append(act.get_value()) return valid_actions
def do_action(self, action): """ First, extract lines according to user's input, within each line holds the coordinate of each tile Then, move and merge tiles :param action: :return: """ lines = self._get_lines(action=action) self._game_board.merge_tile( lines=lines, merge_to_left=Action.left_direction(action)) self._move_count += 1 self._weighted_score = float(self._game_board.get_score()) / float( self._move_count)