#include #include #include #include #include "Generate.h" #include "PuzzlesetEasy.h" #include "PuzzlesetHard.h" #include "PuzzlesetMedium.h" #include "Random.h" Rice::Object wittle_generator_generate_easy(Rice::Object /* self */) { const std::vector>& generator_fns = GetEasyPuzzles(); Generate generator; int choice = Random::rand() % generator_fns.size(); std::cout << "Generate EASY: choice " << std::dec << choice << std::endl; generator_fns.at(choice)(generator); Rice::String str(generator.AsCode()); return str; } Rice::Object wittle_generator_generate_medium(Rice::Object /* self */) { const std::vector>& generator_fns = GetMediumPuzzles(); Generate generator; int choice = Random::rand() % generator_fns.size(); std::cout << "Generate MEDIUM: choice " << std::dec << choice << std::endl; generator_fns.at(choice)(generator); Rice::String str(generator.AsCode()); return str; } Rice::Object wittle_generator_generate_expert(Rice::Object /* self */) { const std::vector>& generator_fns = GetHardPuzzles(); Generate generator; int choice = Random::rand() % generator_fns.size(); std::cout << "Generate EXPERT: choice " << std::dec << choice << std::endl; generator_fns.at(choice)(generator); Rice::String str(generator.AsCode()); return str; } extern "C" void Init_wittle_generator() { Rice::Class rb_cWittleGenerator = Rice::define_class("WittleGenerator") .define_method("generate_easy", &wittle_generator_generate_easy) .define_method("generate_medium", &wittle_generator_generate_medium) .define_method("generate_expert", &wittle_generator_generate_expert); }