Skip to content

Commit

Permalink
add code
Browse files Browse the repository at this point in the history
  • Loading branch information
fl4shk committed Nov 6, 2022
1 parent 2a2633e commit 43c532f
Show file tree
Hide file tree
Showing 9 changed files with 620 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions .gitmodules
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
2 changes: 1 addition & 1 deletion README.md
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
1 change: 1 addition & 0 deletions src/liborangepower_src
45 changes: 45 additions & 0 deletions src/misc_includes.hpp
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
92 changes: 92 additions & 0 deletions src/rule_class.hpp
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
Loading

0 comments on commit 43c532f

Please sign in to comment.