<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import copy
import pygame
from pygame.locals import *

MASU        = 45

class MapDisplay:
    def __init__(self, map_info):
        pygame.init()
        self.map_info           = map_info
        self.row, self.colmun   = map_info.shape

        self.filed_x            = MASU * self.colmun
        self.filed_y            = MASU * self.row
        self.filed_size         = Rect(0,0,self.filed_x,self.filed_y)
        self.screen             = pygame.display.set_mode(self.filed_size.size)
        self.font               = pygame.font.SysFont("timesnewroman",22)
        pygame.display.set_caption("Q-Learning")

    def draw(self, state):
        y, x = state
        for j in range(self.row):
            for i in range(self.colmun):
                if self.map_info[j,i] == 0:
                    pygame.draw.rect(self.screen, (255,255,255), Rect(i*MASU,j*MASU,MASU,MASU))
                elif self.map_info[j,i] == -1:
                    pygame.draw.rect(self.screen, (0,0,0), Rect(i*MASU,j*MASU,MASU,MASU))
                elif self.map_info[j,i] == 3:
                    pygame.draw.rect(self.screen, (0,0,255), Rect(i*MASU,j*MASU,MASU,MASU))
                pygame.draw.rect(self.screen, (50,50,50), Rect(i*MASU,j*MASU,MASU,MASU),1)
        pygame.draw.rect(self.screen, (255,0,0), Rect(x*MASU,y*MASU,MASU,MASU),3)

    def show_policy(self, q_table):
        for x in range(self.row):
            for y in range(self.colmun):
                action = np.array(q_table[:,x,y])
                max_q_action = action.argmax()
                direction = ""
                if max_q_action == 0:
                    direction = u"←"
                elif max_q_action == 1:
                    direction = u"↓"
                elif max_q_action == 2:
                    direction = u"→"
                elif max_q_action == 3:
                    direction = u"↑"
                self.screen.blit(self.font.render(direction, True, (125,125,125)), (y*MASU+MASU/3,x*MASU+MASU/4))<commit_msg>線の太さを変更<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import copy
import pygame
from pygame.locals import *

MASU        = 45

class MapDisplay:
    def __init__(self, map_info):
        pygame.init()
        self.map_info           = map_info
        self.row, self.colmun   = map_info.shape

        self.filed_x            = MASU * self.colmun
        self.filed_y            = MASU * self.row
        self.filed_size         = Rect(0,0,self.filed_x,self.filed_y)
        self.screen             = pygame.display.set_mode(self.filed_size.size)
        self.font               = pygame.font.SysFont("timesnewroman",22)
        pygame.display.set_caption("Q-Learning")

    def draw(self, state):
        y, x = state
        for j in range(self.row):
            for i in range(self.colmun):
                if self.map_info[j,i] == 0:
                    pygame.draw.rect(self.screen, (255,255,255), Rect(i*MASU,j*MASU,MASU,MASU))
                elif self.map_info[j,i] == -1:
                    pygame.draw.rect(self.screen, (0,0,0), Rect(i*MASU,j*MASU,MASU,MASU))
                elif self.map_info[j,i] == 3:
                    pygame.draw.rect(self.screen, (0,0,255), Rect(i*MASU,j*MASU,MASU,MASU))
                pygame.draw.rect(self.screen, (50,50,50), Rect(i*MASU,j*MASU,MASU,MASU),1)
        pygame.draw.rect(self.screen, (255,0,0), Rect(x*MASU,y*MASU,MASU,MASU),5)

    def show_policy(self, q_table):
        for x in range(self.row):
            for y in range(self.colmun):
                action = np.array(q_table[:,x,y])
                max_q_action = action.argmax()
                direction = ""
                if max_q_action == 0:
                    direction = u"←"
                elif max_q_action == 1:
                    direction = u"↓"
                elif max_q_action == 2:
                    direction = u"→"
                elif max_q_action == 3:
                    direction = u"↑"
                self.screen.blit(self.font.render(direction, True, (125,125,125)), (y*MASU+MASU/3,x*MASU+MASU/4))
{'fraction_non_alphanumeric': 0.13680154142581888, 'fraction_numerical': 0.026493256262042388, 'mean_word_length': 1.7197118533071383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1722894', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1468, 'n_words': 237}