WIP: Initial task oriented example. #275
Comments
Ok so I've been trying to test this branch. As per the example in the code, I ran...
I then got the following error:
The whole game froze, and not only that I could only close the tab by killing chrome.exe. @clemens-tolboom what's going on? |
@MattDuffin What's the specific line of code? Don't currently have access to a computer :( |
@ermiyaeskandary I think I've figured it out. The code example in bot.tasks --> MoveToXY is @clemens-tolboom Can you please keep the code comments / examples updated as you change the code? It's annoying to have to kill the whole browser. |
@MattDuffin Great - so the example should be : |
@ermiyaeskandary correct. |
@clemens-tolboom @MattDuffin Currently going towards the middle but doesn't check for food alot but a great start! |
Ok, so having tested this out, I like the idea. It's fun to watch the bot act like it's got a sense of purpose in going to a specific position, and if I want to chill out by one of the walls for a while so I'm not bothered by other snakes, I can set {x: 100, y: 100} or whatever instead of going to the middle. It's good that it looks out for food a bit when it can (and you see the target coordinates change as it's doing so) then goes back to its target, but it misses out on a lot of dead snake food that's right in front of it. I guess you can override that by changing the priority. However, it does tend to crash into snakes a lot more when going to a coordinate, and I think that collision avoidance should be its first priority, even when navigating. The code is a good start though! 👍 |
Thanks for testing that fast. Awesome. This issue has some TODOs of which the moveToXY definitely needs a fix I add the following to the issue summary
And removed
|
// Activate task
bot.getTask('MoveToXY').active = true;
// Set new point
bot.getTask('MoveToXY').point = {x: 21600, y: 21600};
// Add new task
bot.addTask(bot.newTask('dummy'));
// Cannot add duplicate task ID
bot.addTask(bot.newTask('dummy'));
// Delete task
bot.deleteTask('dummy');
// Deleted correct item?
console.log('No dummy found!', bot.getTask('dummy'));
// Report on tasks
bot.getTask('ListTasks').execute(); |
I'm satisfied now scheduler.init();
// Activate task
scheduler.getTask('MoveToXY').active = true;
// Set new point
scheduler.getTask('MoveToXY').point = {x: 21600, y: 21600};
// Add new task
scheduler.addTask(scheduler.newTask('dummy'));
// Cannot add duplicate task ID
scheduler.addTask(scheduler.newTask('dummy'));
// Delete task
scheduler.deleteTask('dummy');
// Deleted correct item?
console.log('No dummy found!', scheduler.getTask('dummy'));
// Report on tasks
scheduler.getTask('ListTasks').execute(); |
The |
When do you want it to run ? |
When a new game starts. |
|
If it only needs to be ran once, stick it somewhere here - https://github.com/ErmiyaEskandary/Slither.io-bot/blob/master/bot.user.js#L1359 |
Whenever a new play starts. |
Perhaps in https://github.com/ErmiyaEskandary/Slither.io-bot/blob/master/bot.user.js#L1306 as the scores also get updated whenever a new play starts ? |
I've also invited you to Gitter at clem****@build2be.com - most of the dev talk goes on here! |
You can add to the menu the key ? |
I'm keeping my fingers crossed for you team programer 👍 |
@Seple adding one key is not an option as we want to toggle all available tasks. I'll try to use number keys to attach the task. Then we have a start. |
key or window look ---> http://s33.postimg.org/ilte1amxr/image.jpg |
Meta
Description
As discussed in #266 but not completed yet here is my first stab.
My basic implementation uses a tasks list with priorities. I have added a few task
Motivation and Context
Problem
Adding new behaviour is difficult as this is hard coded. With A* it was still coded but easier to add new behavior. Furthermore we have a check for food triggered by a window timer which makes it harder too. It is not possible to add behaviour by another user script either.
Solution
This branch decouples the code
by replacing the parts mentioned above into a task scheduler. This allows for prioritise / (de)activate / adding tasks so the behaviour is more dynamic and alterable from outside this project (ie console).
It adds menu entries to toggle tasks to test particular behaviour.
Features
Task list
Screenshots (if appropriate):
Menu
MoveToXY
Types of changes
Checklist:
TODOs
Add surround algorithm from A* branchAdd more from A* branchReceive lots of feedbackschedule.init()
when entering gameThe text was updated successfully, but these errors were encountered: