-
Notifications
You must be signed in to change notification settings - Fork 19
/
ChatEngine.h
66 lines (58 loc) · 2.07 KB
/
ChatEngine.h
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
64
65
66
/**
* RealBot : Artificial Intelligence
* Version : Work In Progress
* Author : Stefan Hendriks
* Url : http://realbot.bots-united.com
**
* DISCLAIMER
*
* History, Information & Credits:
* RealBot is based partially upon the HPB-Bot Template #3 by Botman
* Thanks to Ditlew (NNBot), Pierre Marie Baty (RACCBOT), Tub (RB AI PR1/2/3)
* Greg Slocum & Shivan (RB V1.0), Botman (HPB-Bot) and Aspirin (JOEBOT). And
* everybody else who helped me with this project.
* Storage of Visibility Table using BITS by Cheesemonster.
*
* Some portions of code are from other bots, special thanks (and credits) go
* to (in no specific order):
*
* Pierre Marie Baty
* Count-Floyd
*
* !! BOTS-UNITED FOREVER !!
*
* This project is open-source, it is protected under the GPL license;
* By using this source-code you agree that you will ALWAYS release the
* source-code with your project.
*
**/
// Chatting Engine
#define MAX_BLOCKS 100
#define BLOCK_DEATHS MAX_BLOCKS-1
static const int MAX_SENTENCE_LENGTH = 128;
// Reply block
typedef struct {
// words, hinting that in this block a logical sentence will be to reply with
char word[10][25];
char sentence[50][MAX_SENTENCE_LENGTH]; // at max 50 sentences of 80 characters to reply with
bool bUsed;
}
tReplyBlock;
class cChatEngine {
public:
// variables
tReplyBlock ReplyBlock[MAX_BLOCKS]; // 100 reply blocks reserved in memory
float fThinkTimer; // The chatengine has a 'think timer'.
char sender[30];
char sentence[MAX_SENTENCE_LENGTH];
int iLastBlock;
int iLastSentence;
// functions
void init(); // initialize
void initAndload(); // initialize and load data from file
void think(); // make the chat engine think
// add sentence from any player/bot into memory to handle
void set_sentence(char csender[30], char csentence[MAX_SENTENCE_LENGTH]);
// handles a sentence, decides to reply on it or not.
void handle_sentence();
};