Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Feature/task execution #292

Closed
wants to merge 50 commits into from
Closed

Conversation

clemens-tolboom
Copy link
Collaborator

@clemens-tolboom clemens-tolboom commented Jun 5, 2016

Meta

Issue worked on

#275

Branch

https://github.com/ErmiyaEskandary/Slither.io-bot/tree/feature/task-execution

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

  • CheckForFood: Trigger food scan. It has a changing priority to allow other tasks to be performed.
  • MoveToXY move to the given waypoint
  • AvoidCollisionEnemySnake: Avoid collision with other (enemy) snakes. It using existing code.
  • ListTasks: List the current set of tasks. Has lowest priority

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

// Main bot
go: function() {

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

// Activate task
window.scheduler.getTask('MoveToXY').active = true;

// Set new point
window.scheduler.getTask('MoveToXY').point = {x: 21600, y: 21600};

// Prepare a new Task
var newTask = window.scheduler.newTask('dummy')

// Add new task
window.scheduler.addTask(newTask);

// Cannot add duplicate task ID
window.scheduler.addTask(window.scheduler.newTask('dummy'));

// Delete task
window.scheduler.deleteTask('dummy');

// Report on tasks
window.scheduler.getTask('ListTasks').execute();

Task list

window.scheduler.listTasks()

CheckForFood Active: true Priority: 397 Trigger food scan
AvoidCollisionEnemySnake Active: true Priority: 0 Avoid collision with other (enemy) snakes
_default Active: true Priority: 0 This is the default task which cannot be deactivated.
MoveToXY Active: false Priority: 300 Move to the given way point

Screenshots (if appropriate):

Menu

slither_io

MoveToXY

slither_io

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code adheres to the code style of this project but most importantly of all to the things mentioned in CONTRIBUTING.md and PULL_REQUEST_TEMPLATE.md.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

TODOs

return;
}
console.log(ids, ids[index]);
return ids[index];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected no return value.

@clemens-tolboom
Copy link
Collaborator Author

Thanks @houndci-bot :p

@ermiyaeskandary ermiyaeskandary self-assigned this Jun 5, 2016
@ermiyaeskandary
Copy link
Owner

ermiyaeskandary commented Jun 5, 2016

checkforfood checks for food and eats it.
There's no point for eat.

  • eat doesn't work if checkforfood isn't enabled/on :(

@ermiyaeskandary
Copy link
Owner

ermiyaeskandary commented Jun 5, 2016

I presume for testing this - 3 options, which have to be and are present in the current master bot, **only need to be enabled:

  • avoidcollisionenemysnake
  • checkforfood

(eat) may be one if the bug ^^^ is addressed or simply just remove it .... @clemens-tolboom

@ermiyaeskandary
Copy link
Owner

ermiyaeskandary commented Jun 5, 2016

@clemens-tolboom The overlay is also messed up - the scores don't fully show up

image

@ermiyaeskandary
Copy link
Owner

ermiyaeskandary commented Jun 5, 2016

@clemens-tolboom

Below some results without MoveToXY which are not good I guess :-(

Solved ?

@ChadSki
Copy link
Collaborator

ChadSki commented Jun 6, 2016

Running tests...

  1. feature/task-execution (23aeb46)
  2. develop (10dfdb6)

@ermiyaeskandary
Copy link
Owner

ermiyaeskandary commented Jun 6, 2016

@ChadSki What options are you testing with for feature/task-execution ?

@ChadSki
Copy link
Collaborator

ChadSki commented Jun 6, 2016

Defaults

options

@ermiyaeskandary
Copy link
Owner

@ChadSki 👍

@ChadSki
Copy link
Collaborator

ChadSki commented Jun 6, 2016

It's only been two hours so far, but the results are not looking so great. Current medians below:

  1. feature/task-execution (23aeb46)
    • 4711 (11 games)
    • 1654 (9 games)
    • 3548 (11 games)
    • 1601 (16 games)
  2. develop (10dfdb6)
    • 6410 (14 games)
    • 4877 (13 games)
    • 4727 (9 games)
    • 9815 (6 games)

I'll keep the test running overnight, though.

@ChadSki ChadSki added this to the Task Execution milestone Jun 6, 2016
@clemens-tolboom clemens-tolboom force-pushed the feature/task-execution branch from a23580a to d29adcb Compare July 11, 2016 07:49
@ChadSki
Copy link
Collaborator

ChadSki commented Jul 13, 2016

This pull request has been open for over a month. I think it's best if development happens on the separate branch until it is truly ready for integration.

@ChadSki ChadSki closed this Jul 13, 2016
@clemens-tolboom
Copy link
Collaborator Author

You made me very nervous closing this PR so I pushed my code to git@github.com:clemens-tolboom/Slither.io-bot.git

Note the issue summary has a separate branch https://github.com/ErmiyaEskandary/Slither.io-bot/tree/feature/task-execution but only I am working on it which s**ks

Guess this is goodbye

@ChadSki
Copy link
Collaborator

ChadSki commented Jul 15, 2016

Nervous? The code doesn't go away, if that's what you meant -- the feature/task-execution branch has all your changes intact.

I like to follow your progress but pull requests are really about "I'm ready to merge, can anyone review my changes?" Since this branch isn't ready to be pulled/integrated, it shouldn't be a PR yet.

It's very easy to open a PR so I would recommend doing so once everything is ready for review.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants