<commit_before>////
//    __|  |  | _ _| __  /  __|   \ |
//  \__ \  __ |   |     /   _|   .  |
//  ____/ _| _| ___| ____| ___| _|\_|
//
// Copyright (c) 2017 <NAME>
//
// This library is free software; you can redistribute and modify it
// under the terms of the MIT license. See LICENSE for details.
//

#include <SHIZEN/zrand.h>

#include <stdlib.h>
#include <math.h>
#include <time.h>

#ifdef SHIZ_DEBUG
 #include <stdio.h>
#endif

#include <pcg_basic.h>

static u32 current_seed;

void
z_rand_seed(u32 seed)
{
    pcg32_srandom(seed, 0xda3e39cb94b95bdbULL);
    
    current_seed = seed;
    
#ifdef SHIZ_DEBUG
    printf("Seeding: %d\n", current_seed);
#endif
}

void
z_rand_seed_now()
{
    z_rand_seed((u32)time(NULL));
}

u32
z_rand_get_seed()
{
    return current_seed;
}

u32
z_rand()
{
    return pcg32_random();
}

i32
z_rand_range(i32 const min, i32 const max)
{
    u32 const range = (u32)abs(max - min);
    u32 const r = pcg32_boundedrand(range + 1); // both min and max inclusive
    
    i32 const result = min + (i32)r;
    
    return result;
}

f32
z_randf()
{
    return ldexpf(z_rand(), -32);
}

f32
z_randf_range(f32 const min, f32 const max)
{
    return z_lerp(min, max, z_randf());
}

f32
z_randf_angle()
{
    return z_randf_range((f32)-M_PI,
                         (f32)M_PI);
}

SHIZColor
z_rand_color()
{
    return SHIZColorMake(z_randf(),
                         z_randf(),
                         z_randf(),
                         1);
}

bool
z_rand_choice()
{
    return z_rand_range(0, 1) > 0;
}

bool
z_rand_chance(f32 const percentage)
{
    return z_randf() < percentage;
}<commit_msg>Cleanup and add include symbols<commit_after>////
//    __|  |  | _ _| __  /  __|   \ |
//  \__ \  __ |   |     /   _|   .  |
//  ____/ _| _| ___| ____| ___| _|\_|
//
// Copyright (c) 2017 <NAME>
//
// This library is free software; you can redistribute and modify it
// under the terms of the MIT license. See LICENSE for details.
//

#include <SHIZEN/zrand.h>

#include <stdlib.h> // NULL
#include <math.h> // ldexpf, M_PI
#include <time.h> // time()

#ifdef SHIZ_DEBUG
 #include <stdio.h>
#endif

#include <pcg_basic.h>

static u32 current_seed;

void
z_rand_seed(u32 seed)
{
    pcg32_srandom(seed, 0xda3e39cb94b95bdbULL);
    
    current_seed = seed;
    
#ifdef SHIZ_DEBUG
    printf("Seeding: %d\n", current_seed);
#endif
}

void
z_rand_seed_now()
{
    z_rand_seed((u32)time(NULL));
}

u32
z_rand_get_seed()
{
    return current_seed;
}

u32
z_rand()
{
    return pcg32_random();
}

i32
z_rand_range(i32 const min, i32 const max)
{
    u32 const range = (u32)abs(max - min);
    u32 const r = pcg32_boundedrand(range + 1); // both min and max inclusive
    
    i32 const result = min + (i32)r;
    
    return result;
}

f32
z_randf()
{
    return ldexpf(z_rand(), -32);
}

f32
z_randf_range(f32 const min, f32 const max)
{
    return z_lerp(min, max, z_randf());
}

f32
z_randf_angle()
{
    return z_randf_range((f32)-M_PI, (f32)M_PI);
}

SHIZColor
z_rand_color()
{
    return SHIZColorMake(z_randf(), z_randf(), z_randf(), 1);
}

bool
z_rand_choice()
{
    return z_rand_range(0, 1) > 0;
}

bool
z_rand_chance(f32 const percentage)
{
    return z_randf() < percentage;
}
{'fraction_non_alphanumeric': 0.14156813939016802, 'fraction_numerical': 0.04169259489732421, 'mean_word_length': 2.712471131639723, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4278955', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1337, 'n_words': 286}