<commit_before>//
//  Galaxy.swift
//  GalaxyKit
//
//  Created by <NAME> on 1/5/16.
//  Copyright © 2016 Aranasaurus. All rights reserved.
//

import Foundation
import GameplayKit

public class Galaxy {
    let densityMap: [UInt]
    
    public var continueGeneratingBeyondMap = false
    // All of this density stuff will only be used if `continueGeneratingBeyondMap` is `true` and a sector is requested outside the densityMap.
    public var minDensity = 1
    public var maxDensity = 64
    public lazy var densitySeed: UInt64 = UInt64(Date().timeIntervalSinceReferenceDate)
    public lazy var densityDistribution: GKGaussianDistribution = {
        let source = GKMersenneTwisterRandomSource(seed: self.densitySeed)
        let distribution = GKGaussianDistribution(randomSource: source, lowestValue: self.minDensity, highestValue: self.maxDensity)
        return distribution
    }()

    public subscript(x: UInt, y: UInt) -> Sector {
        let index = Int(x + y)
        if !continueGeneratingBeyondMap {
            precondition(index < densityMap.count, "Sector coordinates out of bounds... sorry this Galaxy _does_ have limits")
            return Sector.init(x, y, numStars: densityMap[index])
        }
        
        if index < densityMap.count {
            return Sector(x, y, numStars: densityMap[index])
        }
        
        return Sector(x, y, numStars: UInt(self.densityDistribution.nextInt()))
    }
    
    public init(densityMap: [UInt] = [], continueGeneratingBeyondMap: Bool = false) {
        self.densityMap = densityMap
        self.continueGeneratingBeyondMap = continueGeneratingBeyondMap
    }
}<commit_msg>why wasn't this a guard to begin with?<commit_after>//
//  Galaxy.swift
//  GalaxyKit
//
//  Created by <NAME> on 1/5/16.
//  Copyright © 2016 Aranasaurus. All rights reserved.
//

import Foundation
import GameplayKit

public class Galaxy {
    let densityMap: [UInt]
    
    public var continueGeneratingBeyondMap = false
    // All of this density stuff will only be used if `continueGeneratingBeyondMap` is `true` and a sector is requested outside the densityMap.
    public var minDensity = 1
    public var maxDensity = 64
    public lazy var densitySeed: UInt64 = UInt64(Date().timeIntervalSinceReferenceDate)
    public lazy var densityDistribution: GKGaussianDistribution = {
        let source = GKMersenneTwisterRandomSource(seed: self.densitySeed)
        let distribution = GKGaussianDistribution(randomSource: source, lowestValue: self.minDensity, highestValue: self.maxDensity)
        return distribution
    }()

    public subscript(x: UInt, y: UInt) -> Sector {
        let index = Int(x + y)
        guard continueGeneratingBeyondMap else {
            precondition(index < densityMap.count, "Sector coordinates out of bounds... sorry this Galaxy _does_ have limits")
            return Sector.init(x, y, numStars: densityMap[index])
        }
        
        if index < densityMap.count {
            return Sector(x, y, numStars: densityMap[index])
        }
        
        return Sector(x, y, numStars: UInt(self.densityDistribution.nextInt()))
    }
    
    public init(densityMap: [UInt] = [], continueGeneratingBeyondMap: Bool = false) {
        self.densityMap = densityMap
        self.continueGeneratingBeyondMap = continueGeneratingBeyondMap
    }
}
{'fraction_non_alphanumeric': 0.08548290341931614, 'fraction_numerical': 0.008998200359928014, 'mean_word_length': 2.9655172413793105, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '742225', 'n_tokens_mistral': 991, 'n_tokens_neox': 918, 'n_words': 280}