-
Notifications
You must be signed in to change notification settings - Fork 0
/
generation-002.js
33 lines (29 loc) · 732 Bytes
/
generation-002.js
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
/**
* CHANGELOG:
* Generation 2: add chatbot functionality
*/
import { generations, evolve } from "./base.js";
import readline from "readline";
const generation = 2;
async function output() {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question("Hello! What's your name? ", (name) => {
console.log(`Nice to meet you, ${name}!`);
rl.question("How can I assist you today? ", (question) => {
console.log(`I'm sorry, ${name}. I'm just a simple chatbot and I don't have the answer to that question.`);
rl.close();
});
});
}
if (generation < generations) {
try {
await evolve(generation);
} catch (error) {
console.error(error);
}
} else {
await output();
}