<commit_before>#include <iostream>
#include <vector>

#include "DFSMazeGenerator.h"
#include "Maze.h"
#include "MazeCell.h"
#include "MazeGenerator.h"
#include "MazeGeneratorType.h"
#include "Point.h"
#include "PrimsMazeGenerator.h"
#include "Stats.h"

Maze::Maze(int _width, int _height, MazeGeneratorType g) : modifiedPoints(), width(2 * _width + 1), height(2 * _height + 1),
               start(1, 1), end(width - 2, height - 2), cells(height, std::vector< MazeCell > (width, MazeCell())),
               currentPosition(start) {
    generate(g);
    setProperties(start, MazeCell::Properties::PART_OF_PATH);
}

Maze::Maze(int width, int height) : Maze(width, height, MazeGeneratorType::PRIMS) {}

void Maze::initGrid() {
    for (int i = 0; i < height; ++i) {
        for (int j = 0; j < width; ++j) {
            if (i % 2 == 0 || j % 2 == 0) cells[i][j] = MazeCell(MazeCell::Type::WALL, MazeCell::Properties::NONE);
            else                          cells[i][j] = MazeCell(MazeCell::Type::OPEN, MazeCell::Properties::NONE);

            modifiedPoints.push(Point(i,j));
        }
    }
}

void Maze::generate(MazeGeneratorType g) {
    initGrid();

    MazeGenerator* generator;

    if (g == MazeGeneratorType::DFS) {
        generator = new DFSMazeGenerator();
    } else if (g == MazeGeneratorType::PRIMS) {
        generator = new PrimsMazeGenerator();
    } else {<commit_msg>Fix segfault from mixed up index values<commit_after>#include <iostream>
#include <vector>

#include "DFSMazeGenerator.h"
#include "Maze.h"
#include "MazeCell.h"
#include "MazeGenerator.h"
#include "MazeGeneratorType.h"
#include "Point.h"
#include "PrimsMazeGenerator.h"
#include "Stats.h"

Maze::Maze(int _width, int _height, MazeGeneratorType g) : modifiedPoints(), width(2 * _width + 1), height(2 * _height + 1),
               start(1, 1), end(width - 2, height - 2), cells(height, std::vector< MazeCell > (width, MazeCell())),
               currentPosition(start) {
    generate(g);
    setProperties(start, MazeCell::Properties::PART_OF_PATH);
}

Maze::Maze(int width, int height) : Maze(width, height, MazeGeneratorType::PRIMS) {}

void Maze::initGrid() {
    for (int y = 0; y < height; ++y) {
        for (int x = 0; x < width; ++x) {
            if (x % 2 == 0 || y % 2 == 0) getRef(x,y) = MazeCell(MazeCell::Type::WALL, MazeCell::Properties::NONE);
            else                          getRef(x,y) = MazeCell(MazeCell::Type::OPEN, MazeCell::Properties::NONE);

            modifiedPoints.push(Point(x,y));
        }
    }
}

void Maze::generate(MazeGeneratorType g) {
    initGrid();

    MazeGenerator* generator;

    if (g == MazeGeneratorType::DFS) {
        generator = new DFSMazeGenerator();
    } else if (g == MazeGeneratorType::PRIMS) {
        generator = new PrimsMazeGenerator();
    } else {
{'fraction_non_alphanumeric': 0.1589779985805536, 'fraction_numerical': 0.0099361249112846, 'mean_word_length': 3.3302611367127497, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, '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': '3457613', 'n_tokens_mistral': 991, 'n_tokens_neox': 963, 'n_words': 218}