Maddie Busig 00303ae3be Refactor fractal generator and fractal classes, begin rewrite
Separating fractal generation run from ruleset generation. After the
ruleset is processed, there is no reason for the group characteristics,
etc to still be used. Additionally, this will avoid the possibility of
the user attempting to use the fractal before ruleset is created and
processed.

Other changes:
Branch rules now use unioned weighted or unweighted group.
Rewrite ruleset creation usage
2025-04-29 04:59:38 -07:00

67 lines
1.9 KiB
C++

#include <cmath>
#include <tonc.h>
#include <mtl/log.hpp>
#include <etl/vector.h>
#include <mtl/exception.hpp>
#include "fractal.hpp"
using namespace mtl;
using namespace fractal;
int main(void) {
REG_DISPCNT = DCNT_MODE3 | DCNT_BG2;
log::debug << "Hello world!" << mtl::endl;
ruleset_t rules;
try {
fixed branch_angle = M_PI_4;
token_id_t walk_petal_length = rules.add_token(token_type_e::walk, 8);
token_id_t walk_petal_side = rules.add_token(token_type_e::walk, 4);
token_id_t rotate_axiom = rules.add_token(token_type_e::rotate, M_PI_2);
token_id_t rotate_petal = rules.add_token(token_type_e::rotate, M_PI_2);
token_id_t rotate_branchr = rules.add_token(token_type_e::rotate, branch_angle);
token_id_t rotate_branchl = rules.add_token(token_type_e::rotate, branch_angle * -2);
token_id_t branch = rules.add_token(token_type_e::empty);
token_id_t petal = rules.add_token(token_type_e::empty);
token_id_t mark = rules.add_token(token_type_e::empty);
log::info << "Added tokens" << endl;
uint32_t axiom_factor = 4;
etl::vector axiom_chr{ branch, rotate_axiom };
group_id_t axiom_grp = rules.add_group_characteristic(axiom_chr, axiom_factor);
etl::vector branch_chr{ petal, rotate_branchr, branch, rotate_branchl, branch };
group_id_t branch_grp = rules.add_group_characteristic(branch_chr);
etl::vector petal_chr{ mark, walk_petal_length, mark, rotate_petal, walk_petal_length, mark };
group_id_t petal_grp = rules.add_group_characteristic(petal_chr);
log::info << "Added group characteristics" << endl;
rules.add_branch_rule(branch, branch_grp);
rules.add_branch_rule(petal, petal_grp);
rules.add_mark_rule(mark, 1);
log::info << "Added rules" << endl;
log::info << "Finished configuring ruleset" << endl;
} catch(const mtl::exception&) {
log::info << "Failed to configure ruleset, caught exception" << endl;
return 0;
}
while (true) {
vid_vsync();
}
return 0;
}