Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0dd005c
emscripten bindings
MPM1107 Apr 13, 2026
e736c8b
add feature descriptions
Kludwisz Apr 17, 2026
146bb51
Merge branch 'main' of https://github.com/MinecraftAtHome/Lootinator
Kludwisz Apr 17, 2026
ab98a25
add release build for windows
Kludwisz Apr 17, 2026
9106361
kgen config probability tests
ScriptLineStudios Apr 19, 2026
84cf520
add addition check for impossible constraints
ScriptLineStudios Apr 19, 2026
67d01c0
kgen config probability tests
ScriptLineStudios Apr 19, 2026
177ab5e
add addition check for impossible constraints
ScriptLineStudios Apr 19, 2026
1f3520d
Merge branch 'dev' of https://github.com/MinecraftAtHome/Lootinator i…
ScriptLineStudios Apr 19, 2026
63f7fe5
remove testing dir
ScriptLineStudios Apr 19, 2026
678c0d8
Add exit error codes
Cactooz Apr 19, 2026
ae42680
clean up old code, test & fix function order DFS
Kludwisz Apr 19, 2026
c39318a
merge changes from upstream
Kludwisz Apr 19, 2026
f14a760
fix test function signature
Kludwisz Apr 19, 2026
883cab0
remove submodules?
Kludwisz Apr 19, 2026
d3dbb9c
actually remove submodules?
Kludwisz Apr 19, 2026
2316f11
Add error codes printing
Cactooz Apr 19, 2026
102c39c
Fix .clang-format duplicate lines
Cactooz Apr 19, 2026
4b9f818
fix: broaden std::runtime_error to std::exception to handle json pars…
Kludwisz Apr 22, 2026
79d0561
Merge branch 'dev' of https://github.com/MinecraftAtHome/Lootinator i…
Kludwisz Apr 22, 2026
0e63283
fix critical bugs in both single and non single kernels, bump version…
ScriptLineStudios Apr 26, 2026
ddc4f5d
Merge branch 'dev' of https://github.com/MinecraftAtHome/Lootinator i…
ScriptLineStudios Apr 26, 2026
791dd84
emscripten bindings
MPM1107 Apr 13, 2026
e3caa35
update wasm bindings
MPM1107 Apr 26, 2026
aed303f
mpm oopsie fix
MPM1107 Apr 26, 2026
4fc301e
fix tests
MPM1107 Apr 26, 2026
f973608
Merge branch 'webassembly' of https://github.com/MinecraftAtHome/Loot…
MPM1107 Apr 26, 2026
ed85b07
Build actions (#45)
ScriptLineStudios Apr 26, 2026
9528513
Merge branch 'dev' of https://github.com/MinecraftAtHome/Lootinator i…
Kludwisz Apr 26, 2026
8353539
fix example
Kludwisz Apr 26, 2026
cd23fd2
Build actions on main (#46)
ScriptLineStudios Apr 26, 2026
8df3dce
Merge branch 'main' into dev
ScriptLineStudios Apr 26, 2026
fb6e3d6
fix merge
ScriptLineStudios Apr 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ BinPackArguments: false

AllowAllParametersOfDeclarationOnNextLine: false
BinPackParameters: true
ColumnLimit: 0

AlignAfterOpenBracket: DontAlign
ContinuationIndentWidth: 4

ColumnLimit: 100
SpaceBeforeParens: ControlStatements
Expand Down
53 changes: 34 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
name: lootinator-release-builds
name: lootinator-release-build

on: [push]
on:
push:
branches:
- main

jobs:
linux:
name: build/release/linux
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4

- name: setup
run: |
sudo apt update
sudo apt install build-essentials

- name: build
mkdir build && cd build && cmake ..
make -B -j8

- uses: actions/upload-artifact@v4
with:
name: lootinator-cli-linux
path: ./${{ github.event.repository.name }}/build/cli/lootinator-cli


- uses: actions/checkout@v4
with:
submodules: recursive
- name: setup
run: |
sudo apt update
- name: build
run: |
mkdir build && cd build && cmake ..
make -B -j8
- uses: actions/upload-artifact@v4
with:
name: lootinator-cli-linux
path: ./build/cli/lootinator-cli
windows:
name: build/release/windows
runs-on: [windows-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: build
run: |
cmake -S . -B build
cmake --build build --config Release
- uses: actions/upload-artifact@v4
with:
name: lootinator-cli-windows.exe
path: .\build\cli\Release\lootinator-cli.exe
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[submodule "external/json"]
path = external/json
url = https://github.com/nlohmann/json.git
[submodule "external/flag.h"]
path = external/flag.h
url = https://github.com/tsoding/flag.h
[submodule "external/CLI11"]
path = external/CLI11
url = https://github.com/CLIUtils/CLI11
[submodule "external/clipp"]
path = external/clipp
url = https://github.com/muellan/clipp
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.11`)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand All @@ -16,5 +16,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_subdirectory(lootinator)
add_subdirectory(example)
add_subdirectory(cli)

if(EMSCRIPTEN)
add_subdirectory(web)
else()
add_subdirectory(example)
add_subdirectory(cli)
endif()
2 changes: 1 addition & 1 deletion cli/constraints.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"item": "minecraft:gold_block",
"range": {
"min": 5,
"min": 50,
"max": 1000
},
"slot": 0
Expand Down
70 changes: 44 additions & 26 deletions cli/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,56 @@ int main(int argc, char** argv) {
std::string constraint_file = "";
std::string version_str = "";
std::string output_file = "a.cu";
std::string seed_output_file = "loot_seeds.txt";

auto cli = (
(clipp::required("--loot-table") & clipp::value("file_path.json", loot_table),
clipp::required("--constraint-file") & clipp::value("file_path.json", constraint_file),
clipp::required("-o", "--output") & clipp::value("filepath", output_file),
clipp::option("-sc", "--seedcracking").set(seedcracking).doc("seedcracking mode"),
clipp::option("-sk", "--single-kernel").set(single_kernel).doc("single kernel mode"),
clipp::option("-v", "--version")
.doc("the target Minecraft version e.g. 1.16 or latest, currently latest is 26.1") &
clipp::value("version", version_str))
| clipp::required("--list-versions").set(list_versions).doc("list supported Minecraft versions")
);
static_assert(mc::VersionRange::MC_LATEST == mc::VersionRange::MC_1_21_11_TO_26_1,
auto cli =
((clipp::required("--loot-table") &
clipp::value("file_path.json", loot_table).if_missing([] {
std::cout << "Failed: you need to specify a loot table\n";
}),
clipp::required("--constraints") &
clipp::value("file_path.json", constraint_file).if_missing([] {
std::cout << "Failed: you need to specify a constraint file\n";
}),
clipp::option("-o", "--output") &
clipp::value("filepath.cu", output_file)
.doc("specify the output file for cuda, default is " + output_file),
clipp::option("-sc", "--seedcracking").set(seedcracking).doc("seedcracking mode"),
clipp::option("-sk", "--single-kernel").set(single_kernel).doc("single kernel mode"),
clipp::option("-so", "--seed-output") &
clipp::value("file_path.txt", seed_output_file)
.doc("specify the output file for seeds, default is " + seed_output_file),
clipp::required("-v", "--version")
.doc("the target Minecraft version e.g. 1.16 or latest, currently latest is "
"26.2") &
clipp::value("version", version_str).if_missing([] {
std::cout << "Failed: you need to specify a minecraft version\n";
}))

| clipp::required("--list-versions")
.set(list_versions)
.doc("list supported Minecraft versions"));
static_assert(mc::VersionRange::MC_LATEST == mc::VersionRange::MC_1_21_11_TO_26_2,
"update the doc of version to reflect the latest version");

if (!clipp::parse(argc, argv, cli)) {
std::cout << clipp::make_man_page(cli, argv[0]);
exit(1);
exit(loot::LootinatorErrorKind::INVALID_ARGUMENTS);
}

if (list_versions) {
std::cout << "Supported Minecraft Versions:\n";
for (const auto& v : mc::get_supported_versions()) {
std::cout << v << "\n";
for (const auto& version : mc::get_supported_versions()) {
std::cout << version << "\n";
}
exit(0);
exit(loot::LootinatorErrorKind::SUCCESS);
}

mc::VersionRange version = mc::parse_version(version_str);
if (version == mc::MC_UNDEFINED) {
fprintf(stderr, "Lootinator failed: version is undefined!\n");
exit(1);
int error_code = loot::LootinatorErrorKind::INVALID_ARGUMENTS;
std::cout << "Lootinator failed (" << error_code << "): version is undefined.\n";
exit(error_code);
}

std::ofstream fout(output_file);
Expand All @@ -54,23 +72,23 @@ int main(int argc, char** argv) {
loot::LootinatorError err = loot::LootinatorError(loot::LootinatorErrorKind::SUCCESS);
if (single_kernel) {
err = loot::generate_best_pipeline_heur(
loot_table, constraint_file, version, seedcracking, &s);
loot_table, constraint_file, version, seedcracking, &s, seed_output_file);
} else {
err =
loot::generate_benchmark_source(loot_table, constraint_file, version, seedcracking, &s);
err = loot::generate_benchmark_source(
loot_table, constraint_file, version, seedcracking, &s, seed_output_file);
}

if (err.kind == loot::LootinatorErrorKind::SUCCESS) {
fout << s;
std::cout << "Cuda generation was successful.\n";
std::cout << "==== Selected Options ====\n";
std::cout << "========= Results =========\n";
std::cout << " Output File: " << output_file << "\n";
std::cout << " Version Range: " << mc::get_version_from_enum(version) << "\n";
std::cout << " Constraints: " << constraint_file << "\n";
std::cout << " Seedcracking: " << (seedcracking ? "true\n" : "false\n");
std::cout << " Single Kernel: " << (single_kernel ? "true\n" : "false\n");
std::cout << " Output File: " << output_file << "\n";
std::cout << "==========================\n";
std::cout << "===========================\n";
} else {
std::cout << "Lootinator failed: " << err.message << '\n';
std::cout << "Lootinator failed (" << err.kind << "): " << err.message << '\n';
exit(err.kind);
}
}
2 changes: 1 addition & 1 deletion example/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main() {
std::string s;

loot::LootinatorError err = loot::generate_best_pipeline_heur(
loot_table_file, constraints_file, mc::MC_1_21_TO_1_21_10, true, &s);
loot_table_file, constraints_file, mc::MC_1_21_TO_1_21_10, true, &s, "loot_seeds.txt");

if (err.kind == loot::LootinatorErrorKind::SUCCESS) {
fout << s;
Expand Down
1 change: 0 additions & 1 deletion external/CLI11
Submodule CLI11 deleted from 30d783
1 change: 0 additions & 1 deletion external/flag.h
Submodule flag.h deleted from 7d3699
11 changes: 2 additions & 9 deletions lootinator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ add_library(lootinator
include/lootinator/lootinator.h
include/lootinator/mc/minecraft.hpp
include/lootinator/probability/loot_prob.h
include/lootinator/template/helpers.h
include/lootinator/template/kernel/naive_bruteforce_template.h
include/lootinator/template/kernel_template.h
include/lootinator/template/template.h
include/lootinator/utility/debug.h
include/lootinator/utility/enum_bimap.hpp
include/lootinator/utility/mth.h
Expand All @@ -33,17 +29,14 @@ add_library(lootinator
src/lootinator.cpp
src/mc/minecraft.cpp
src/probability/loot_prob.cpp
src/template/helpers.cpp
src/template/kernel/naive_bruteforce_template.cpp
src/template/kernel_template.cpp
src/template/template.cpp
src/utility/debug.cpp
)

target_include_directories(lootinator PUBLIC include)

set(TEST_FILES
tests/smoke_tests.cpp
tests/function_order_dfs.cpp
tests/test_kgen_config.cpp
)

# TODO: compiler flags, (-O3, warnings, etc)
Expand Down
4 changes: 3 additions & 1 deletion lootinator/include/lootinator/kgen/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ namespace kgen {

// any extra scuffed stuff goes here
bool using_nvrtc = false;
std::string seeds_output;

KernelGenConfig(mc::VersionRange version, std::string loot_table, std::string constraints,
bool seedcracking);
bool seedcracking, std::string seeds_output);

void traverse_and_derive(data::LootTreeNode* root, bool** edges);
void construct_order(bool** edges, const int num_functions, data::LootTreeNode* root);
Expand All @@ -32,6 +33,7 @@ namespace kgen {

struct ConfiguredKernel {
std::string kernel_name;
std::string seeds_output;
std::string code;

uint64_t total_threads;
Expand Down
12 changes: 7 additions & 5 deletions lootinator/include/lootinator/lootinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ namespace loot {
BAD_CONSTRAINT_FILE,
BAD_LOOT_TABLE,
RANGE_PARSE,
INTERNAL_ERROR
INTERNAL_ERROR,
MC_VERSION_UNDEFINED,
INVALID_ARGUMENTS
};

std::string parse_errno(LootinatorErrorKind error);
Expand All @@ -46,19 +48,19 @@ namespace loot {

LootinatorError generate_best_pipeline_heur(const std::string loot_table_filepath,
const std::string constraint_filepath, const mc::VersionRange version_range,
const bool use_seedcracking_mode, std::string* result);
const bool use_seedcracking_mode, std::string* result, std::string seeds_output);

LootinatorError generate_benchmark_source(const std::string loot_table_filepath,
const std::string constraint_filepath, const mc::VersionRange version_range,
const bool use_seedcracking_mode, std::string* result);
const bool use_seedcracking_mode, std::string* result, std::string seeds_output);

LootinatorError generate_best_pipeline_heur_from_string(const std::string loot_table,
const std::string constraints, const mc::VersionRange version_range,
const bool use_seedcracking_mode, std::string* result);
const bool use_seedcracking_mode, std::string* result, std::string seeds_output);

LootinatorError generate_benchmark_source_from_string(const std::string loot_table,
const std::string constraints, const mc::VersionRange version_range,
const bool use_seedcracking_mode, std::string* result);
const bool use_seedcracking_mode, std::string* result, std::string seeds_output);
} // namespace loot

#endif
2 changes: 1 addition & 1 deletion lootinator/include/lootinator/mc/minecraft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace mc {
X(MC_1_14_TO_1_15) \
X(MC_1_16_TO_1_20) \
X(MC_1_21_TO_1_21_10) \
X(MC_1_21_11_TO_26_1)
X(MC_1_21_11_TO_26_2)

enum VersionRange {
#define X(v) v,
Expand Down
18 changes: 0 additions & 18 deletions lootinator/include/lootinator/template/helpers.h

This file was deleted.

This file was deleted.

29 changes: 0 additions & 29 deletions lootinator/include/lootinator/template/kernel_template.h

This file was deleted.

Loading