<commit_before>#pragma once

#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#include <Windowsx.h>

#include <cstdio>

#include <vector>
#include <random>
#include <cassert>

#include <chrono>
#include <thread>
#include <mutex>


// TODO: move all cond var notifies out of locks

namespace __gameInternal {

#ifdef GWINDOW_DEBUG
    #define gassert(test) assert(test);
#else
    #define gassert(test)
#endif

/// Represents point with real coordinates
struct Point {
    double x;
    double y;
    Point(double x, double y): x(x), y(y) {}
    Point() {}
};

/// Represnts line withr eal coordinates
struct Line {
    Point from;
    Point to;
    Line(double fromX, double fromY, double toX, double toY): from(fromX, fromY), to(toX, toY) {}
    Line(Point from, Point to): from(from), to(to) {}
    Line() {}
};

/// Game settings grouped in struct
struct GameConfig {
    int width;
    int height;
    Point target;
    double targetRadius;
    int maxReflect;
    int mirrorCount;
    std::vector<Line> mirrors;

    static bool readConfig(GameConfig & cfg, const char * cfgFileName) {
        auto confFile = std::shared_ptr<FILE>(fopen(cfgFileName, "r"), [](FILE *file) {
            if (file) {
                fclose(file);
            }
        });
        if (!confFile) {
            return false;
        }

#define readFromCofig(dest, format)\
        if (1 != fscanf(confFile.get(), format " ", dest)) {\
            puts("Failed to read" #dest " from config.");\
            return false;\
        }
<commit_msg>Add assert and print for missing config<commit_after>#pragma once

#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#include <Windowsx.h>

#include <cstdio>

#include <vector>
#include <random>
#include <cassert>

#include <chrono>
#include <thread>
#include <mutex>


// TODO: move all cond var notifies out of locks

namespace __gameInternal {

#ifdef GWINDOW_DEBUG
    #define gassert(test) assert(test);
#else
    #define gassert(test)
#endif

/// Represents point with real coordinates
struct Point {
    double x;
    double y;
    Point(double x, double y): x(x), y(y) {}
    Point() {}
};

/// Represnts line withr eal coordinates
struct Line {
    Point from;
    Point to;
    Line(double fromX, double fromY, double toX, double toY): from(fromX, fromY), to(toX, toY) {}
    Line(Point from, Point to): from(from), to(to) {}
    Line() {}
};

/// Game settings grouped in struct
struct GameConfig {
    int width;
    int height;
    Point target;
    double targetRadius;
    int maxReflect;
    int mirrorCount;
    std::vector<Line> mirrors;

    static bool readConfig(GameConfig & cfg, const char * cfgFileName) {
        auto confFile = std::shared_ptr<FILE>(fopen(cfgFileName, "r"), [](FILE *file) {
            if (file) {
                fclose(file);
            }
        });
        gassert(confFile.get() && "Missing config file!");
        if (!confFile) {
            puts("Config file is not found, it must be in working directory!");
            return false;
        }

#define readFromCofig(dest, format)\
        if (1 != fscanf(confFile.get(), format " ", dest)) {\
            puts("Failed to read" #dest " from config.");\
            return false;\
        }

{'fraction_non_alphanumeric': 0.12883245586869, 'fraction_numerical': 0.0006193868070610096, 'mean_word_length': 2.738425925925926, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '2597677', 'n_tokens_mistral': 1028, 'n_tokens_neox': 1016, 'n_words': 315}