1
0
Fork 0
mirror of https://github.com/isledecomp/isle.git synced 2025-05-02 08:53:54 -04:00
isle/tools/entropy.py
Christian Semmler ca1c8b2be6
Add build-with-entropy pipeline ()
* Try entropy build

* Fix

* Updates

* Remove file

* Fix

* Add seed parameter to entropy.sh

* echo SEED used

* Try build pipeline changes

* Add python setup

* Fix pipeline

* Increase number of samples, add entropy to isle and config

* Try 32 samples

* Empty commit for another CI run

* Try 50 samples

* Empty commit for another CI run

* Empty commit for another CI run

* Empty commit for another CI run

* Empty commit for another CI run

* Empty commit for another CI run

* Empty commit for another CI run

* Empty commit for another CI run

* Empty commit for another CI run

* Trigger CI with 100 entropy samples

* Trigger CI with 100 entropy samples

* Trigger CI with 100 entropy samples

* Trigger CI with 100 entropy samples

* Trigger CI with 100 entropy samples

* Trigger CI with 100 entropy samples

* Trigger CI with 100 entropy samples

* Trigger CI with 100 entropy samples

* Trigger CI with 100 entropy samples

* Trigger CI with 100 entropy samples

* Update

* Echo seed

* Update text

* Fix requirements.txt

* Cancel previous CI workflows

* Try only build,yml

* Empty commit - should stop earlier build

* Fix upload
2025-03-05 23:25:39 +01:00

45 lines
1.1 KiB
Python

import random
import string
import sys
# Parameters for tweaking:
MAX_CLASSES = 10
MAX_FUNC_PER_CLASS = 10
# Only the unique suffix, not counting "Class" or "Function"
CLASS_NAME_LEN = 6
FUNC_NAME_LEN = 8
def random_camel_case(length: int) -> str:
"""Return a random string with first letter capitalized."""
return "".join(
[
random.choice(string.ascii_uppercase),
*random.choices(string.ascii_lowercase, k=length - 1),
]
)
# If the first parameter is an integer, use it as the seed.
try:
seed = int(sys.argv[1])
except (IndexError, ValueError):
seed = random.randint(0, 10000)
random.seed(seed)
print(f"// Seed: {seed}\n")
num_classes = random.randint(1, MAX_CLASSES)
for i in range(num_classes):
class_name = "Class" + random_camel_case(CLASS_NAME_LEN)
print(f"class {class_name} {{")
num_functions = random.randint(1, MAX_FUNC_PER_CLASS)
for j in range(num_functions):
function_name = "Function" + random_camel_case(FUNC_NAME_LEN)
print(f"\tinline void {function_name}() {{}}")
print(f"}};\n")
print()