<commit_before>screen = pygame.display.set_mode(
        (0, 0),     # (0, 0) resolution defaults to the user's screen size
        pygame.HWSURFACE | pygame.DOUBLEBUF     #!|pygame.FULLSCREEN)
        )
#! Decide how the window should be when the game opens. Fullscreen? Borderless? Windowed?
screen_width = screen.get_width()
screen_height = screen.get_height()
MONITOR_WIDTH = screen_width
MONITOR_HEIGHT = screen_height

# Defining a function to change the screen settings after it has been created
def reinitialise_screen(resolution=(screen_width, screen_height), mode="fullscreen"):
    global error
    try:
        global screen, screen_width, screen_height
        screen_width = resolution[0]
        screen_height = resolution[1]
        if mode == "fullscreen":
            screen = pygame.display.set_mode(
                resolution,
                pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.FULLSCREEN
                )
        elif mode == "windowed":
            # Positioning the window in the centre of the screen
            os.environ['SDL_VIDEO_WINDOW_POS'] = "".join((
                str((MONITOR_WIDTH - screen_width)/2), ",",
                str((MONITOR_HEIGHT - screen_height)/2)
                ))
            screen = pygame.display.set_mode(
                resolution,
                pygame.HWSURFACE | pygame.DOUBLEBUF
                )
        elif mode == "borderless":
            os.environ['SDL_VIDEO_WINDOW_POS'] = "0,0"
            screen = pygame.display.set_mode(
                resolution,
                pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.NOFRAME
                )
        else:
            raise Exception("".join(("Unknown mode for reinitialise_screen(): \"", mode, "\" "
                                     "[syntax error].")))
    except Exception as error:
        log("".join(("Failed to reinitialise screen in ", mode, " mode "
                     "at ", str(screen_width), "x", str(screen_height), " resolution")))

#! This (below) could all be removed, along with reinitialise_screen,
# if you decide to have a fixed resolution.
# resolutions = [_list of tuples of available resolutions_]
# if (MONITOR_WIDTH, MONITOR_HEIGHT) not in resolutions:
#      screen_width = 0
#      screen_height = 0
#      for resolution in resolutions:
#          if resolution[0] <= MONITOR_WIDTH:
#              if screen_width < resolution[0]:
#                  screen_width = resolution[0]
#                  screen_height = resolution[1]
#              elif (screen_width == resolution[0] and
#                    resolution[1] <= MONITOR_HEIGHT and
#                    screen_height < resolution[1]):
#                  screen_height = resolution[1]
#
#      reinitialise_screen(screen_width, screen_height)

pygame.display.set_caption("insertnamehere (Alpha 1.0)")
#! pygame.display.set_icon()    add the path to an image for the icon as the argument
<commit_msg>Small adjustments to initialise screen. It's neater now.<commit_after>def monitor_info():
    info = pygame.display.Info()
    return info.current_w, info.current_h

# Defining a function to change the screen settings after it has been created
def initialise_screen(resolution=(0, 0), mode="fullscreen"):
    global error
    try:
        global screen, screen_width, screen_height
        screen_width = resolution[0]
        screen_height = resolution[1]
        if mode == "fullscreen":
            screen = pygame.display.set_mode(
                resolution,
                pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.FULLSCREEN
                )
        elif mode == "windowed":
            # Positioning the window in the centre of the screen
            os.environ['SDL_VIDEO_WINDOW_POS'] = "".join((
                str((MONITOR_WIDTH - screen_width)/2), ",",
                str((MONITOR_HEIGHT - screen_height)/2)
                ))
            screen = pygame.display.set_mode(
                resolution,
                pygame.HWSURFACE | pygame.DOUBLEBUF
                )
        elif mode == "borderless":
            os.environ['SDL_VIDEO_WINDOW_POS'] = "0,0"
            screen = pygame.display.set_mode(
                resolution,
                pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.NOFRAME
                )
        else:
            raise Exception("".join(("Unknown mode for reinitialise_screen(): \"", mode, "\" "
                                     "[syntax error].")))
    except Exception as error:
        log("".join(("Failed to reinitialise screen in ", mode, " mode "
                     "at ", str(screen_width), "x", str(screen_height), " resolution")))

# Initialising screen for the first time
MONITOR_WIDTH, MONITOR_HEIGHT = monitor_info()
screen_width, screen_height = MONITOR_WIDTH, MONITOR_HEIGHT
#! Decide how the window should be when the game opens. Fullscreen? Borderless? Windowed?
# How big should it be? User's monitor dimensions? Something else?
initialise_screen((1280, 720), "windowed")

#! These could be added to initialise_screen()
pygame.display.set_caption("insertnamehere (Alpha 1.0)")
#! pygame.display.set_icon()    add the path to an image for the icon as the argument

{'fraction_non_alphanumeric': 0.1001161890007746, 'fraction_numerical': 0.007552285050348567, 'mean_word_length': 2.2566204287515763, 'pattern_counts': {'":': 6, '<': 7, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3727152', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1434, 'n_words': 381}