2022-12-31 09:28:05 -05:00
|
|
|
#pragma once
|
|
|
|
|
2022-12-31 10:02:48 -05:00
|
|
|
#include <array>
|
|
|
|
|
2022-12-31 09:28:05 -05:00
|
|
|
namespace geode {
|
|
|
|
class BaseSeedValue {
|
|
|
|
public:
|
|
|
|
BaseSeedValue() = default;
|
|
|
|
BaseSeedValue(BaseSeedValue const& other) = default;
|
|
|
|
BaseSeedValue(BaseSeedValue&& other) = default;
|
|
|
|
BaseSeedValue& operator=(BaseSeedValue const& other) = default;
|
|
|
|
BaseSeedValue& operator=(BaseSeedValue&& other) = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GEODE_SEED_VALUE_COMMON_OPS() \
|
|
|
|
SeedValue& operator=(int value) { \
|
|
|
|
internalValue() = value; \
|
|
|
|
internalRandom() = value + internalSeed(); \
|
|
|
|
return *this; \
|
|
|
|
} \
|
|
|
|
int value() { \
|
|
|
|
internalValue() = internalRandom() - internalSeed(); \
|
|
|
|
return internalValue(); \
|
|
|
|
} \
|
|
|
|
operator int() { return this->value(); }
|
|
|
|
|
2022-12-31 10:02:48 -05:00
|
|
|
class SeedValueSR : public BaseSeedValue {
|
|
|
|
private:
|
|
|
|
using SeedValue = SeedValueSR;
|
|
|
|
std::array<int, 2> m_values;
|
|
|
|
|
|
|
|
int& internalSeed() {
|
|
|
|
return m_values[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
int& internalRandom() {
|
|
|
|
return m_values[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
using BaseSeedValue::BaseSeedValue;
|
|
|
|
|
|
|
|
SeedValueSR(int value, int seed) : m_values({seed, value + seed}) {}
|
|
|
|
|
|
|
|
SeedValue& operator=(int value) {
|
|
|
|
internalRandom() = value + internalSeed();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
int value() {
|
|
|
|
return internalRandom() - internalSeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
operator int() {
|
|
|
|
return this->value();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class SeedValueRS : public BaseSeedValue {
|
|
|
|
private:
|
|
|
|
using SeedValue = SeedValueRS;
|
|
|
|
std::array<int, 2> m_values;
|
|
|
|
|
|
|
|
int& internalRandom() {
|
|
|
|
return m_values[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
int& internalSeed() {
|
|
|
|
return m_values[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
using BaseSeedValue::BaseSeedValue;
|
|
|
|
|
|
|
|
SeedValueRS(int value, int seed) : m_values({value + seed, seed}) {}
|
|
|
|
|
|
|
|
SeedValue& operator=(int value) {
|
|
|
|
internalRandom() = value + internalSeed();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
int value() {
|
|
|
|
return internalRandom() - internalSeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
operator int() {
|
|
|
|
return this->value();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-12-31 09:50:11 -05:00
|
|
|
class SeedValueVRS : public BaseSeedValue {
|
2022-12-31 09:28:05 -05:00
|
|
|
private:
|
2022-12-31 09:50:11 -05:00
|
|
|
using SeedValue = SeedValueVRS;
|
2022-12-31 10:02:48 -05:00
|
|
|
std::array<int, 3> m_values;
|
|
|
|
|
2022-12-31 09:28:05 -05:00
|
|
|
int& internalValue() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[0];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalRandom() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[1];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalSeed() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[2];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
using BaseSeedValue::BaseSeedValue;
|
|
|
|
|
2022-12-31 10:02:48 -05:00
|
|
|
SeedValueVRS(int value, int seed) : m_values({value, value + seed, seed}) {}
|
2022-12-31 09:28:05 -05:00
|
|
|
|
|
|
|
GEODE_SEED_VALUE_COMMON_OPS();
|
|
|
|
};
|
|
|
|
|
2022-12-31 09:50:11 -05:00
|
|
|
class SeedValueVSR : public BaseSeedValue {
|
2022-12-31 09:28:05 -05:00
|
|
|
private:
|
2022-12-31 09:50:11 -05:00
|
|
|
using SeedValue = SeedValueVSR;
|
2022-12-31 10:02:48 -05:00
|
|
|
std::array<int, 3> m_values;
|
|
|
|
|
2022-12-31 09:28:05 -05:00
|
|
|
int& internalValue() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[0];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalSeed() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[1];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalRandom() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[2];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
using BaseSeedValue::BaseSeedValue;
|
|
|
|
|
2022-12-31 10:02:48 -05:00
|
|
|
SeedValueVSR(int value, int seed) : m_values({value, seed, value + seed}) {}
|
2022-12-31 09:28:05 -05:00
|
|
|
|
|
|
|
GEODE_SEED_VALUE_COMMON_OPS();
|
|
|
|
};
|
|
|
|
|
2022-12-31 09:50:11 -05:00
|
|
|
class SeedValueRVS : public BaseSeedValue {
|
2022-12-31 09:28:05 -05:00
|
|
|
private:
|
2022-12-31 09:50:11 -05:00
|
|
|
using SeedValue = SeedValueRVS;
|
2022-12-31 10:02:48 -05:00
|
|
|
std::array<int, 3> m_values;
|
|
|
|
|
2022-12-31 09:28:05 -05:00
|
|
|
int& internalRandom() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[0];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalValue() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[1];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalSeed() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[2];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
using BaseSeedValue::BaseSeedValue;
|
|
|
|
|
2022-12-31 10:02:48 -05:00
|
|
|
SeedValueRVS(int value, int seed) : m_values({value + seed, value, seed}) {}
|
2022-12-31 09:28:05 -05:00
|
|
|
|
|
|
|
GEODE_SEED_VALUE_COMMON_OPS();
|
|
|
|
};
|
|
|
|
|
2022-12-31 09:50:11 -05:00
|
|
|
class SeedValueRSV : public BaseSeedValue {
|
2022-12-31 09:28:05 -05:00
|
|
|
private:
|
2022-12-31 09:50:11 -05:00
|
|
|
using SeedValue = SeedValueRSV;
|
2022-12-31 10:02:48 -05:00
|
|
|
std::array<int, 3> m_values;
|
|
|
|
|
2022-12-31 09:28:05 -05:00
|
|
|
int& internalRandom() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[0];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalSeed() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[1];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalValue() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[2];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
using BaseSeedValue::BaseSeedValue;
|
|
|
|
|
2022-12-31 10:02:48 -05:00
|
|
|
SeedValueRSV(int value, int seed) : m_values({value + seed, seed, value}) {}
|
2022-12-31 09:28:05 -05:00
|
|
|
|
|
|
|
GEODE_SEED_VALUE_COMMON_OPS();
|
|
|
|
};
|
|
|
|
|
2022-12-31 09:50:11 -05:00
|
|
|
class SeedValueSVR : public BaseSeedValue {
|
2022-12-31 09:28:05 -05:00
|
|
|
private:
|
2022-12-31 09:50:11 -05:00
|
|
|
using SeedValue = SeedValueSVR;
|
2022-12-31 10:02:48 -05:00
|
|
|
std::array<int, 3> m_values;
|
|
|
|
|
2022-12-31 09:28:05 -05:00
|
|
|
int& internalSeed() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[0];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalValue() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[1];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalRandom() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[2];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
using BaseSeedValue::BaseSeedValue;
|
|
|
|
|
2022-12-31 10:02:48 -05:00
|
|
|
SeedValueSVR(int value, int seed) : m_values({seed, value, value + seed}) {}
|
2022-12-31 09:28:05 -05:00
|
|
|
|
|
|
|
GEODE_SEED_VALUE_COMMON_OPS();
|
|
|
|
};
|
|
|
|
|
2022-12-31 09:50:11 -05:00
|
|
|
class SeedValueSRV : public BaseSeedValue {
|
2022-12-31 09:28:05 -05:00
|
|
|
private:
|
2022-12-31 09:50:11 -05:00
|
|
|
using SeedValue = SeedValueSRV;
|
2022-12-31 10:02:48 -05:00
|
|
|
std::array<int, 3> m_values;
|
|
|
|
|
2022-12-31 09:28:05 -05:00
|
|
|
int& internalSeed() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[0];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalRandom() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[1];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int& internalValue() {
|
2022-12-31 10:02:48 -05:00
|
|
|
return m_values[2];
|
2022-12-31 09:28:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
using BaseSeedValue::BaseSeedValue;
|
|
|
|
|
2022-12-31 10:02:48 -05:00
|
|
|
SeedValueSRV(int value, int seed) : m_values({seed, value + seed, value}) {}
|
2022-12-31 09:28:05 -05:00
|
|
|
|
|
|
|
GEODE_SEED_VALUE_COMMON_OPS();
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef GEODE_SEED_VALUE_COMMON_OPS
|
|
|
|
} // namespace geode
|