} return closestPlayer; } function huntPlayer(){ var huntedBot=closestPlayer(); console.log("Hunting bot: "+ huntedBot.id); myDir=bot.findPath(myPos,[huntedBot.pos.x,huntedBot.pos.y]); } /* * * This Code Sets your direction based on myDir. If you are trying to go to a place that you can't reach, you move randomly. * * Otherwise you move in the direction set by your code. Feel free to change this code if you want. */ if(myDir === "none") { console.log("Going Random!"); var rand = Math.floor(Math.random() * 4); var dirs = ["north", "south", "east", "west"]; bot.goDir = dirs[rand]; } else { bot.goDir = myDir; } ///////////* DON'T REMOVE ANTYTHING BELOW THIS LINE *////////////// resolve(); }); } bot.runGame();
return this.self.life <= 50 }, shouldDrink: function() { return this.self.life <= 50 }, drink: function() { this.dir = this.move_to(this.closest(this.bot.taverns)) } } Vind.prototype.botBrain = function() { return new Promise(function(resolve, reject) { var bot = new Bot(vind); bot.state = new (require('machine'))().generateTree(require('./tree.json'), bot, Bot.states) bot.state = bot.state.tick(); bot.state = bot.state.tick(); bot.state = bot.state.tick(); console.log('Running Behavior:', colors.green(bot.state.identifier)) console.log('Moving:', colors.magenta(bot.dir)) vind.goDir = bot.dir resolve(); }); } vind.runGame();