mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-22 15:51:16 +00:00
Update
This commit is contained in:
parent
5bb733603d
commit
43fed35196
53
.github/workflows/build.yml
vendored
53
.github/workflows/build.yml
vendored
@ -108,14 +108,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
instance: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
instance: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
|
||||||
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
|
||||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
|
||||||
50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
|
|
||||||
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
|
|
||||||
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
|
||||||
80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
|
|
||||||
90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -145,7 +138,7 @@ jobs:
|
|||||||
# Get the first 8 characters of the SHA (enough for a decent seed)
|
# Get the first 8 characters of the SHA (enough for a decent seed)
|
||||||
SHA_PREFIX=$(echo "${{ github.sha }}" | cut -c 1-8)
|
SHA_PREFIX=$(echo "${{ github.sha }}" | cut -c 1-8)
|
||||||
|
|
||||||
tools/entropy.sh $((16#$SHA_PREFIX + ${{ matrix.instance }}))
|
python3 tools/entropy.py $((16#$SHA_PREFIX + ${{ matrix.instance }})) > entropy.h
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
shell: cmd
|
shell: cmd
|
||||||
@ -239,12 +232,12 @@ jobs:
|
|||||||
reccmp-project detect --what original --search-path legobin
|
reccmp-project detect --what original --search-path legobin
|
||||||
reccmp-project detect --what recompiled --search-path build
|
reccmp-project detect --what recompiled --search-path build
|
||||||
|
|
||||||
- name: Denoise Accuracy
|
- name: Summarize Accuracy
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
reccmp-denoise --samples $(find build-entropy -type f -name "CONFIGPROGRESS.json") --output CONFIGPROGRESS.json
|
reccmp-reccmp -S CONFIGPROGRESS.SVG --svg-icon assets/config.png --target CONFIG --json CONFIGPROGRESS.json
|
||||||
reccmp-denoise --samples $(find build-entropy -type f -name "ISLEPROGRESS.json") --output ISLEPROGRESS.json
|
reccmp-reccmp -S ISLEPROGRESS.SVG --svg-icon assets/isle.png --target ISLE --json ISLEPROGRESS.json
|
||||||
reccmp-denoise --samples $(find build-entropy -type f -name "LEGO1PROGRESS.json") --output LEGO1PROGRESS.json
|
reccmp-reccmp -S LEGO1PROGRESS.SVG --svg-icon assets/lego1.png --target LEGO1 --json LEGO1PROGRESS.json
|
||||||
|
|
||||||
- name: Compare Accuracy With Current Master
|
- name: Compare Accuracy With Current Master
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -257,9 +250,31 @@ jobs:
|
|||||||
curl -fLSs -o LEGO1PROGRESS-old.json $RELEASE_URL/LEGO1PROGRESS.json || echo "" >LEGO1PROGRESS-old.json
|
curl -fLSs -o LEGO1PROGRESS-old.json $RELEASE_URL/LEGO1PROGRESS.json || echo "" >LEGO1PROGRESS-old.json
|
||||||
|
|
||||||
# Compare with current master
|
# Compare with current master
|
||||||
reccmp-denoise --diff CONFIGPROGRESS-old.json CONFIGPROGRESS.json
|
reccmp-reccmp --target CONFIG --diff CONFIGPROGRESS-old.json || echo "Current master not found"
|
||||||
reccmp-denoise --diff ISLEPROGRESS-old.json ISLEPROGRESS.json
|
reccmp-reccmp --target ISLE --diff ISLEPROGRESS-old.json || echo "Current master not found"
|
||||||
reccmp-denoise --diff LEGO1PROGRESS-old.json LEGO1PROGRESS.json
|
reccmp-reccmp --target LEGO1 --diff LEGO1PROGRESS-old.json || echo "Current master not found"
|
||||||
|
|
||||||
|
- name: Aggregate Accuracy
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
reccmp-aggregate --samples $(find build-entropy -type f -name "CONFIGPROGRESS.json") --output CONFIGPROGRESS-agg.json
|
||||||
|
reccmp-aggregate --samples $(find build-entropy -type f -name "ISLEPROGRESS.json") --output ISLEPROGRESS-agg.json
|
||||||
|
reccmp-aggregate --samples $(find build-entropy -type f -name "LEGO1PROGRESS.json") --output LEGO1PROGRESS-agg.json
|
||||||
|
|
||||||
|
- name: Compare Aggregate Accuracy With Current Master
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
RELEASE_URL: https://github.com/isledecomp/isle/releases/download/continuous
|
||||||
|
run: |
|
||||||
|
# Download the current master state
|
||||||
|
curl -fLSs -o CONFIGPROGRESS-agg-old.json $RELEASE_URL/CONFIGPROGRESS-agg.json || echo "" >CONFIGPROGRESS-agg-old.json
|
||||||
|
curl -fLSs -o ISLEPROGRESS-agg-old.json $RELEASE_URL/ISLEPROGRESS-agg.json || echo "" >ISLEPROGRESS-agg-old.json
|
||||||
|
curl -fLSs -o LEGO1PROGRESS-agg-old.json $RELEASE_URL/LEGO1PROGRESS-agg.json || echo "" >LEGO1PROGRESS-agg-old.json
|
||||||
|
|
||||||
|
# Compare with current master
|
||||||
|
reccmp-aggregate --diff CONFIGPROGRESS-agg-old.json CONFIGPROGRESS-agg.json || echo "Current master not found"
|
||||||
|
reccmp-aggregate --diff ISLEPROGRESS-agg-old.json ISLEPROGRESS-agg.json || echo "Current master not found"
|
||||||
|
reccmp-aggregate --diff LEGO1PROGRESS-agg-old.json LEGO1PROGRESS-agg.json || echo "Current master not found"
|
||||||
|
|
||||||
- name: Test Exports
|
- name: Test Exports
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -285,9 +300,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: Accuracy Report
|
name: Accuracy Report
|
||||||
path: |
|
path: |
|
||||||
CONFIGPROGRESS.*
|
CONFIGPROGRESS*
|
||||||
ISLEPROGRESS.*
|
ISLEPROGRESS*
|
||||||
LEGO1PROGRESS.*
|
LEGO1PROGRESS*
|
||||||
|
|
||||||
upload:
|
upload:
|
||||||
name: Upload artifacts
|
name: Upload artifacts
|
||||||
|
|||||||
45
tools/entropy.py
Normal file
45
tools/entropy.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
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()
|
||||||
@ -1,67 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Output file
|
|
||||||
OUTPUT_FILE="entropy.h"
|
|
||||||
|
|
||||||
# Function to generate a CamelCase string of given length
|
|
||||||
generate_name() {
|
|
||||||
local seed="$1"
|
|
||||||
local length="$2"
|
|
||||||
local char_count=0
|
|
||||||
local random_bytes=""
|
|
||||||
|
|
||||||
while [ "$char_count" -lt "$length" ]; do
|
|
||||||
random_bytes+=$(od -vAn -N4 -tu4 < /dev/urandom | tr -d '[:space:]')
|
|
||||||
char_count=$((char_count + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# Use the provided seed for the random number generation. Crucially, re-seed bash's
|
|
||||||
# RANDOM for each name.
|
|
||||||
RANDOM="$seed"
|
|
||||||
|
|
||||||
local result=""
|
|
||||||
for ((i=0; i<length; i++)); do
|
|
||||||
# Get a pseudo-random number between 0 and 25 (inclusive)
|
|
||||||
local rand_index=$((RANDOM % 26))
|
|
||||||
# Convert to lowercase ASCII character (a=97)
|
|
||||||
local char_code=$((97 + rand_index))
|
|
||||||
# Append to the result string
|
|
||||||
result+=$(printf "\\$(printf '%o' "$char_code")")
|
|
||||||
done
|
|
||||||
echo "$result" | sed -E 's/(^|_)([a-z])/\U\2/g'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parse command-line arguments
|
|
||||||
if [ "$#" -ne 1 ]; then
|
|
||||||
echo "Usage: $0 <seed_number>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
SEED="$1"
|
|
||||||
# Initialize the random number generator with the seed
|
|
||||||
RANDOM="$SEED"
|
|
||||||
|
|
||||||
# Generate a random number of classes (between 1 and 10)
|
|
||||||
NUM_CLASSES=$((RANDOM % 10 + 1))
|
|
||||||
|
|
||||||
> "$OUTPUT_FILE" # Clear or create the output file
|
|
||||||
|
|
||||||
echo "// Seed: $SEED" > "$OUTPUT_FILE"
|
|
||||||
echo >> "$OUTPUT_FILE"
|
|
||||||
|
|
||||||
for ((i=0; i<NUM_CLASSES; i++)); do
|
|
||||||
CLASS_NAME="Class$(generate_name "$((SEED + i * 100))" 6)"
|
|
||||||
echo "class $CLASS_NAME {" >> "$OUTPUT_FILE"
|
|
||||||
|
|
||||||
# Generate a random number of methods (between 1 and 10)
|
|
||||||
NUM_METHODS=$((RANDOM % 10 + 1))
|
|
||||||
for ((j=0; j<NUM_METHODS; j++)); do
|
|
||||||
METHOD_NAME="Function$(generate_name "$((SEED + i * 100 + j))" 8)"
|
|
||||||
echo -e "\tinline void $METHOD_NAME() {}" >> "$OUTPUT_FILE"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "};" >> "$OUTPUT_FILE"
|
|
||||||
echo >> "$OUTPUT_FILE"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Generated $NUM_CLASSES classes in $OUTPUT_FILE using seed $SEED"
|
|
||||||
Loading…
Reference in New Issue
Block a user