blob: 5669592a1ac6a0e0d183912a27434ba286c7a98a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#include <functional>
#include <iostream>
#include <rice/rice.hpp>
#include <vector>
#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<std::function<void(Generate&)>>& 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<std::function<void(Generate&)>>& 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<std::function<void(Generate&)>>& 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);
}
|