blob: e6974a0c617b33c762054dced0d884c3da14a1f0 (
plain)
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
|
#define WALK_LEN 200
// #define FILE_PATH "files/in.txt"
#define FILE_PATH "files/shakespeare.txt"
// #define FILE_PATH "files/south-park-the-aristocrats.txt"
// #define PRINT_CHAIN
// #define PRINT_ITEM_FREQUENCY
#define PRINT_ON_WALK
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ITEM_CAP 4000
#include "markov.h"
int ITEMS = 0;
double chain[ITEM_CAP][ITEM_CAP] = {0};
char item_names[ITEM_CAP][64] = {0};
void set_stack();
int main(void)
{
set_stack();
srand(time(NULL));
generate_chain();
take_walk();
#ifdef PRINT_CHAIN
print_chain();
#endif
return 0;
}
// for stack
#include <sys/resource.h>
void set_stack()
{
const rlim_t kStackSize = 64L * 1024L * 1024L; // min stack size = 64 Mb
struct rlimit rl;
int result;
if(getrlimit(RLIMIT_STACK, &rl) == 0) {
if (rl.rlim_cur < kStackSize) {
rl.rlim_cur = kStackSize;
if((result = setrlimit(RLIMIT_STACK, &rl)) != 0)
fprintf(stderr, "setrlimit returned result = %d\n", result);
}
}
}
|