diff --git a/main.js b/main.js index 8018238..5e8cc97 100644 --- a/main.js +++ b/main.js @@ -24,9 +24,9 @@ function main() { console.log(profiles); const { load_memory, init_message } = settings; - for (const profile of profiles) { + for (let i=0; i { + addViewer(this.bot, count_id); + // wait for a bit so stats are not undefined await new Promise((resolve) => setTimeout(resolve, 1000)); diff --git a/src/agent/viewer.js b/src/agent/viewer.js new file mode 100644 index 0000000..6ce8a27 --- /dev/null +++ b/src/agent/viewer.js @@ -0,0 +1,8 @@ +import settings from '../../settings.js'; +import prismarineViewer from 'prismarine-viewer'; +const mineflayerViewer = prismarineViewer.mineflayer; + +export function addViewer(bot, count_id) { + if (settings.show_bot_views) + mineflayerViewer(bot, { port: 3000+count_id, firstPerson: true, }); +} \ No newline at end of file diff --git a/src/process/agent-process.js b/src/process/agent-process.js index 21b6c2c..5409ba5 100644 --- a/src/process/agent-process.js +++ b/src/process/agent-process.js @@ -1,9 +1,10 @@ import { spawn } from 'child_process'; export class AgentProcess { - start(profile, load_memory=false, init_message=null) { + start(profile, load_memory=false, init_message=null, count_id=0) { let args = ['src/process/init-agent.js', this.name]; args.push('-p', profile); + args.push('-c', count_id); if (load_memory) args.push('-l', load_memory); if (init_message) diff --git a/src/process/init-agent.js b/src/process/init-agent.js index d461ee0..81c3ce1 100644 --- a/src/process/init-agent.js +++ b/src/process/init-agent.js @@ -22,6 +22,12 @@ const argv = yargs(args) alias: 'm', type: 'string', description: 'automatically prompt the agent on startup' + }) + .option('count_id', { + alias: 'c', + type: 'number', + default: 0, + description: 'identifying count for multi-agent scenarios', }).argv -new Agent().start(argv.profile, argv.load_memory, argv.init_message); +new Agent().start(argv.profile, argv.load_memory, argv.init_message, argv.count_id); diff --git a/viewer.html b/viewer.html new file mode 100644 index 0000000..737b046 --- /dev/null +++ b/viewer.html @@ -0,0 +1,69 @@ + + + Viewer + + + +
+ + + + +
+ + +