-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
620 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*.o | ||
*.a | ||
*.d | ||
*.elf | ||
*.sav* | ||
*.ss* | ||
*.gdb_history* | ||
*.sw[po] | ||
tags | ||
types_*.taghl | ||
*.ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "submodules/liborangepower"] | ||
path = submodules/liborangepower | ||
url = [email protected]:fl4shk/liborangepower.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# wfc | ||
Wave Function Collapse in C++ | ||
Wave Function Collapse in C++20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../submodules/liborangepower/src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef src_misc_includes_hpp | ||
#define src_misc_includes_hpp | ||
|
||
// src/misc_includes.hpp | ||
|
||
#include "liborangepower_src/misc/misc_includes.hpp" | ||
#include "liborangepower_src/misc/misc_output_funcs.hpp" | ||
#include "liborangepower_src/misc/misc_input_classes.hpp" | ||
#include "liborangepower_src/misc/misc_types.hpp" | ||
#include "liborangepower_src/misc/misc_utility_funcs.hpp" | ||
#include "liborangepower_src/misc/misc_bitwise_funcs.hpp" | ||
#include "liborangepower_src/misc/misc_defines.hpp" | ||
#include "liborangepower_src/gen_class_innards_defines.hpp" | ||
#include "liborangepower_src/strings/string_conversion_stuff.hpp" | ||
#include "liborangepower_src/strings/sconcat_etc.hpp" | ||
#include "liborangepower_src/strings/string_extra_stuff.hpp" | ||
#include "liborangepower_src/containers/defer_call_stuff.hpp" | ||
#include "liborangepower_src/containers/std_hash_stuff.hpp" | ||
#include "liborangepower_src/concepts/misc_concepts.hpp" | ||
#include "liborangepower_src/concepts/math_concepts.hpp" | ||
#include "liborangepower_src/concepts/std_container_concepts.hpp" | ||
#include "liborangepower_src/concepts/std_stream_concepts.hpp" | ||
#include "liborangepower_src/concepts/is_specialization_concepts.hpp" | ||
#include "liborangepower_src/math/vec2_classes.hpp" | ||
#include "liborangepower_src/math/shape_2d_classes.hpp" | ||
//#include "liborangepower_src/time/time_stuff.hpp" | ||
//#include "liborangepower_src/arg_parser_class.hpp" | ||
|
||
using namespace liborangepower::misc_output; | ||
using namespace liborangepower::misc_input; | ||
using namespace liborangepower::integer_types; | ||
using namespace liborangepower::misc_util; | ||
using namespace liborangepower::bitwise; | ||
using namespace liborangepower::strings; | ||
using namespace liborangepower::containers; | ||
namespace concepts = liborangepower::concepts; | ||
using namespace liborangepower::math; | ||
using namespace liborangepower::time; | ||
//using namespace liborangepower::arg_parse; | ||
|
||
#include <pcg_random.hpp> | ||
#include <queue> | ||
#include <stack> | ||
|
||
#endif // src_misc_includes_hpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#ifndef src_rule_class_hpp | ||
#define src_rule_class_hpp | ||
|
||
// src/rule_class.hpp | ||
|
||
#include "misc_includes.hpp" | ||
|
||
namespace wfc { | ||
//-------- | ||
enum class Dir: u32 { | ||
Left = 0, | ||
Top = 1, | ||
Right = 2, | ||
Bottom = 3, | ||
Bad = 4, | ||
}; | ||
constexpr inline Dir reverse(Dir d) { | ||
switch (d) { | ||
//-------- | ||
case Dir::Left: | ||
return Dir::Right; | ||
case Dir::Top: | ||
return Dir::Bottom; | ||
case Dir::Right: | ||
return Dir::Left; | ||
case Dir::Bottom: | ||
return Dir::Top; | ||
default: | ||
return Dir::Bad; | ||
//-------- | ||
} | ||
} | ||
constexpr inline std::ostream& operator << ( | ||
std::ostream& os, const Dir& d | ||
) { | ||
switch (d) { | ||
//-------- | ||
case Dir::Left: | ||
return osprintout(os, "Dir::Left"); | ||
case Dir::Top: | ||
return osprintout(os, "Dir::Top"); | ||
case Dir::Right: | ||
return osprintout(os, "Dir::Right"); | ||
case Dir::Bottom: | ||
return osprintout(os, "Dir::Bottom"); | ||
default: | ||
return osprintout(os, "Dir::Bad"); | ||
//-------- | ||
} | ||
} | ||
|
||
class Rule final { | ||
public: // variables | ||
u32 t0, t1; // tiles | ||
Dir d; // direction | ||
public: // functions | ||
constexpr inline auto operator <=> ( | ||
const Rule& to_cmp | ||
) const = default; | ||
constexpr inline Rule reverse() const { | ||
Rule ret = *this; | ||
std::swap(ret.t0, ret.t1); | ||
ret.d = wfc::reverse(ret.d); | ||
//return Rule{.t0=t1, .t1=t0, .d=::reverse(d)}; | ||
return ret; | ||
} | ||
}; | ||
using RuleUset = std::unordered_set<Rule>; | ||
constexpr inline std::ostream& operator << ( | ||
std::ostream& os, const Rule& rule | ||
) { | ||
os | ||
<< "{" << "\'" << rule.t0 << "\' << " | ||
<< "\'" << rule.t1 << "\' << " | ||
<< rule.d << "}"; | ||
return os; | ||
} | ||
//-------- | ||
} // namespace wfc | ||
|
||
namespace std { | ||
//-------- | ||
template<> | ||
struct hash<wfc::Rule> { | ||
std::size_t operator () (const wfc::Rule& key) const noexcept { | ||
return hash_va(key.t0, key.t1, key.d); | ||
} | ||
}; | ||
//-------- | ||
} // namespace std | ||
|
||
#endif // src_rule_class_hpp |
Oops, something went wrong.