aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/src/main.c b/src/main.c
index 8b412ca..e6974a0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,33 +1,52 @@
-// ----------------- OPTIONS ----------------- //
-#define FILE_PATH "files/in.txt"
+#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 WALK_LEN 100000
-
-#define PRINT_CHAIN
-#define PRINT_ITEM_FREQUENCY
-// #define PRINT_ON_WALK
-// #define SAVE_TO_FILE_ON_WALK "out.txt"
-// --------------- END OPTIONS --------------- //
+// #define PRINT_CHAIN
+// #define PRINT_ITEM_FREQUENCY
+#define PRINT_ON_WALK
#include <stdio.h>
+#include <stdlib.h>
#include <time.h>
-#define ITEM_CAP 1024
-int ITEMS = 0;
+#define ITEM_CAP 4000
+#include "markov.h"
+int ITEMS = 0;
double chain[ITEM_CAP][ITEM_CAP] = {0};
char item_names[ITEM_CAP][64] = {0};
-#include "markov.h"
+void set_stack();
int main(void)
{
+ set_stack();
+
srand(time(NULL));
generate_chain();
+ take_walk();
#ifdef PRINT_CHAIN
print_chain();
#endif
- take_walk();
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);
+ }
+ }
+}