-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
57 lines (51 loc) · 1.31 KB
/
Copy pathmain.c
File metadata and controls
57 lines (51 loc) · 1.31 KB
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
#include <stdio.h>
#include "god.h"
#include "limits.h"
#define everlasting const
#define HOLYINT_MAX ULONG_MAX
#define QUESTION_MAX 255
typedef char believersword_t;
typedef char godsword_t;
typedef int divineint_t;
everlasting godsword_t* responses[] = {
// affirmative
"It is certain.",
"It is decidedly so.",
"Without a doubt.",
"Yes definitely.",
"You may rely on it.",
"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Yes.",
"Signs point to yes.",
// unsure
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
// negative
"Don't count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."
};
everlasting godsword_t* speakToGod(believersword_t* question)
{
holyint_t y = godsRandom();
y = ( y & HOLYINT_MAX) >> 16;
y = (y++ + y++);
godsword_t shift = -(godsRandom() % (godsRandom() % 31)) - (godsRandom() % 20);
y = y << shift;
y = y % (sizeof(responses) / sizeof(everlasting godsword_t*));
return responses[y];
}
divineint_t main()
{
printf("Ask God a question: ");
believersword_t question[QUESTION_MAX];
gets(question); // Yes, gets is unsafe. No, I don't care.
printf("God's answer: %s\n", speakToGod(question));
}