Sau1707 / ModernBot

A Bot for Grepolis
MIT License
24 stars 21 forks source link

PoC: Task queue & Idle manager #41

Closed vitdolinek closed 1 month ago

vitdolinek commented 8 months ago

Hey, I've implemented a basic queue for bot tasks and idle manager.

Idle manager A simple mechanism that checks whether the user clicked or moved the mouse within 30 seconds. If the user is marked as idle, the task queue will automatically start performing queued tasks, otherwise, it'll wait for the user to be idle.

Task queue Performs tasks that were queued, one at a time. Each task has its' own unique ID to prevent task duplication.

Key features:

Implementation details:

To be done:

I'd like to know your opinion if this is the way you'd like to go.

Sau1707 commented 8 months ago

Oh this is a big one ;)

I'm gonna take a bit of time to check it. The idea it's awesome, right now it's quite easy to catch the bot, this kind of updates are very important to fix that.

Gonna come back as soon as I have a bit of free time!

Sau1707 commented 8 months ago

I'm currently cleaning the code, and slowly moving to this approach, it will be added eventually but it's gonna takes a bit.

We have to see how to make the quee so that if there is an autotrain active for example, it gives priority to it, but at the same time it doesn't jump from town to town immediately like it doesn't right now, because can be seen from the logs and this creates a lot of bugs.

So probably an auto delay has to be implemented if a task with higher priorities it's coming in the near future, like a real player, need to have time to change the polis.

The other problem is that right now you see that the build command comes from a different town, this means that the bot needs to change the town automatically, or all the build and train sistem has to be changed with a different method (using the premium advisor)

I'm moving in this direction

vitdolinek commented 8 months ago

@Sau1707 The issue with a command coming from a different town - that is easily solvable. In src/constants/events.js, each command has defined its' function in eventsCommand which can be any synchronous or asynchronous function meaning you can put before the API call mechanism to switch towns.

There is also priority constant. It is not implemented yet but I've planned on putting commands to queue with priority and then an algorithm that will take commands out of queue based on their priority.

As long as it acts as queue (priority queue), we don't have to introduce any auto delay.

WYT?

Sau1707 commented 8 months ago

Sorry for the late response.

Sound good, thank you! However before implementing all of this, I still have to clean the old code and change some things here and there. Might take a bit of time, sorry about it.

NotXina commented 6 months ago

any plans for auto-dodge?

Sau1707 commented 6 months ago

any plans for auto-dodge?

take a look at #37