<commit_before>import shutil
import time
import os

import sys
sys.path.append('../')

from constants import PLAYER_X, PLAYER_Y, DANCE, UP

class MapVisualizer():
    def __init__(self, fps=3):
        self.fps = fps
        self.max_cols, self.max_raws = shutil.get_terminal_size()

    def check_map_size(self, map_matrix):
        if len(map_matrix) > self.max_raws:
            raise ValueError("Raw len {} > {}".format(len(map_matrix), self.max_raws))

        for raw in map_matrix:
            if len(raw) > self.max_cols:
                raise ValueError("Col len {} > {}".format(len(raw), self.max_cols))

    def draw_matrix(self, matrix):
        for raw in matrix:
            line = ''
            for tile in raw:
                line = line + tile
            print(line)

    def draw(self, map_matrix, actions, score):
        self.check_map_size(map_matrix)

        os.system('clear')
        if actions is not None:
            if actions[PLAYER_X] == DANCE or actions[PLAYER_Y] == DANCE:
                for cycle in range(10):
                    for raw_index, raw in enumerate(map_matrix):
                        try:
                            xcol_index = raw.index(PLAYER_X)
                            xraw_index = raw_index
                        except ValueError:
                            pass

                        try:
                            ycol_index = raw.index(PLAYER_Y)
                            yraw_index = raw_index
                        except ValueError:
                            pass

                    if actions[PLAYER_X] == DANCE:
                        map_matrix[xraw_index][xcol_index] = PLAYER_X.lower() if cycle % 2 else PLAYER_X.upper()
                    if actions[PLAYER_Y] == DANCE:
                        map_matrix[yraw_index][ycol_index] = PLAYER_Y.lower() if cycle % 2 else PLAYER_Y.upper()

                    self.draw_matrix(map_matrix)
                    time.sleep(0.5)
                    os.system('clear')

        self.draw_matrix(map_matrix)
        time.sleep(1 / self.fps)

    def game_over(self, score):
        pass


def generate_raw_map(raws, cols):
    matrix = [['.' for _ in range(cols)] for _ in range(raws)]
    matrix[int(raws/2)][int(cols/2)] = PLAYER_X<commit_msg>Dance frames configurable and at fps speed<commit_after>import shutil
import time
import os

import sys
sys.path.append('../')

from constants import PLAYER_X, PLAYER_Y, DANCE, UP

class MapVisualizer():
    def __init__(self, fps=3, dance_frames=4):
        self.fps = fps
        self.dance_frames = dance_frames
        self.max_cols, self.max_raws = shutil.get_terminal_size()

    def check_map_size(self, map_matrix):
        if len(map_matrix) > self.max_raws:
            raise ValueError("Raw len {} > {}".format(len(map_matrix), self.max_raws))

        for raw in map_matrix:
            if len(raw) > self.max_cols:
                raise ValueError("Col len {} > {}".format(len(raw), self.max_cols))

    def draw_matrix(self, matrix):
        for raw in matrix:
            line = ''
            for tile in raw:
                line = line + tile
            print(line)

    def draw(self, map_matrix, actions, score):
        self.check_map_size(map_matrix)

        os.system('clear')
        if actions is not None:
            if actions[PLAYER_X] == DANCE or actions[PLAYER_Y] == DANCE:
                for cycle in range(self.dance_frames):
                    for raw_index, raw in enumerate(map_matrix):
                        try:
                            xcol_index = raw.index(PLAYER_X)
                            xraw_index = raw_index
                        except ValueError:
                            pass

                        try:
                            ycol_index = raw.index(PLAYER_Y)
                            yraw_index = raw_index
                        except ValueError:
                            pass

                    if actions[PLAYER_X] == DANCE:
                        map_matrix[xraw_index][xcol_index] = PLAYER_X.lower() if cycle % 2 else PLAYER_X.upper()
                    if actions[PLAYER_Y] == DANCE:
                        map_matrix[yraw_index][ycol_index] = PLAYER_Y.lower() if cycle % 2 else PLAYER_Y.upper()

                    self.draw_matrix(map_matrix)
                    time.sleep(1 / self.fps)
                    os.system('clear')

        self.draw_matrix(map_matrix)
        time.sleep(1 / self.fps)

    def game_over(self, score):
        pass


def generate_raw_map(raws, cols):
    matrix = [['.' for _ in range(cols)] for _ in range(raws)]
    matrix[int(raws/2)][int(cols/2)] = PLAYER_X
{'fraction_non_alphanumeric': 0.09644234890698672, 'fraction_numerical': 0.0038576939562794685, 'mean_word_length': 1.5699339207048457, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5479332', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1351, 'n_words': 309}