A bot that plays Agar.io. It looks at the cells around it, works out which directions are dangerous, and steers somewhere it can eat without being eaten.
Install aposbot.user.js with Tampermonkey or Violentmonkey and open agar.io.
- Press
Tif you want to use the manual controls. - Press
Bto switch to the next bot when more than one is installed. - Press
Rif you want to toggle the line and dot drawing. - Press
Dto toggle the dark mode. - Press
Pto toggle restarting after a death. - Press
ESCfor the option menu.
window.AposBot does the same things without the keys.
AposBot.start() // same as pressing T
AposBot.stop()
AposBot.status() // mass, cells, state, how settled the steering is
AposBot.bots // the names use() takes
AposBot.use('aposbot') // switch to one of them
AposBot.bot // the one that is running
AposBot.world // the cells, the camera and the map
AposBot.backend // the socket hook and the input path
AposBot.dump() // the frames it has seen, as hexAposBot.dump() is what to attach to an issue when the bot stops reading the game. agar.io moves its frame layout every so often, and the panel says PROTOCOL DESYNC with a hex window around the byte that stopped the parse in the console when it does.
A bot is a factory that takes the world API and returns mainLoop, keyAction and displayText. mainLoop returns where you want to go in absolute game coordinates:
AposBot.backend.useBot(function (api) {
return {
name: 'MyBot',
keyAction: function (key) {},
displayText: function () { return []; },
mainLoop: function () {
var me = api.getPlayer()[0];
if (!me) return [];
return [me.x + 100, me.y];
},
};
});Paste that into the console and it takes over on the next frame. To install a bot rather than paste it, push the same factory onto window.aposBots from a userscript of your own, which works whichever of the two loads first. B goes to the next bot from there, so the built-in one is a keypress away and yours is another one back. You can read BOT-API.md for more information about what's available. Every accessor you can read the world through, what a cell carries, how the camera moves, and the debug drawing.
If you start working on a bot, make sure to start an issue and tell me about it so that I can add it to the bot list on Alternate Bots
Your userscript manager handles this. aposbot.user.js carries @updateURL and @downloadURL, so it updates itself on the manager's normal schedule. The bot also checks the GitHub releases API once an hour and mentions a new version in the console.
You can sponsor the project on GitHub Sponsors if the bot is useful to you.
MIT. See LICENSE.