OnceBot - Elvenar Bot

Thank you @djvj , yes some help could speed up the development a lot. I often rely on other people to open a game client and share the game mechanics and the parts of the interactions to be automated. Usually, there is no time left for me to open a game client myself.

This year, I have not opened the game client and do not remember the necessary interactions. As far as I remember, the bot did collect coins by clicking representations of coins floating above buildings.

Is that enough functionality of the first version of the bot? Do we need anything more than that?

Since I never used the bot, I am unfamiliar of the extent of it’s functionality or exactly how it determined when a coin can be clicked. I thought it would at least que up new production, which would really be ideal, that and train troops. So Ideally a bot would do this:

Coins

  • Click ~50 pixels under coin (coin itself hovers over building above it)

Production

  • Same as above, but once all production is gone off screen, click building, then click next que, close popup window

Barracks

  • Click new Barracks/Training Grounds, que up next soldier, close popup window

These are the main 3 that require users to really check in constantly.

1 Like

Wow, thank you, that was fast. Let’s do this.

Do we have a sample image of how the coin looks in the game client? When I have a sample image in original quality, I can use that to train a function that located the coin on the screen.

Here’s the different icons, taken at fullscreen 1080p res.
https://imgur.com/a/wZYylXh

1 Like

Thank you very much! I see you chose PNG as the file format. I wonder if I should convert it to BMP in the training repository to simplify the parsing. Windows Explorer says the PNG file is 447 KB in size. I used Paint.NET to save a representation in BMP. That one is 483 KB large. So the conversion to BMP did not increase the size much. I expect we don’t use any precision with this conversion.

Yea it probably prefers the raw bitmap image for .net. Changing format shouldn’t be an issue. If you need another one saved as BMP for any reason, I can grab another. Precision will play the role in avoiding false positives.

Thank you for the offer. I guess the mapping I got by saving in the Paint.NET tool is just as good so I will work with that one for now.

If I counted correctly, this image contains three instances of the coin. Using all three examples for the training should yield a robust pattern :+1:

1 Like

@sk3nn1x thank you for the test.

I got around to begin a bot for Elvenar. You can run the last version from bots/implement/applications/elvenar/elvenar-bot at 3c41e57a3ef423b9f55ad0cd177aba9e34edb847 · Viir/bots · GitHub

@djvj what do you think? Does this work for you so far?

Just trying to figure out how to run these botlab bots, following a guide. So give me more time please.

The easiest way might be to copy the link into this text box:

So In the readme, you have this:

Selecting the game window

Select the window the bot should operate on in the “pick window” tab.
To select the game window, check the checkbox “pick next focused window” and then click on the game window.
If the window has been successfully selected, its title will be shown under “last picked window”.

There is no pick window tab. All I see is this:
https://imgur.com/Lw5FsPL
So basically I have no ability to pick the window/tab the bot should be looking at.

Good point. We need some way to pick the target window. I forgot to mention that. Here is how it works today: The bot picks the topmost window in the display order, the one in the front. This selection happens once when starting the bot. The bot then remembers the window address and continues working on the same window.

To use this bot, bring the target window to the foreground after pressing the button to run the bot. When the bot displays the window title in the status text, you know it has completed the selection.

In the screenshot you posted, the bot status text shows it picked the window of the botlab client.

Ok I see that I have to click play, then immediately select the browser window, otherwise it picks the bot window, which is topmost at the time. I did that, the bot sees the correct window, gets its screenshot, finds 5 object in 5 locations, which there are actually 16 on screen, and sits there and nothing ever happens.

I work in the window with title ‘Elvenar - Fantasy City Builder Game - Google Chrome’.
Operate bot:
The last screenshot had a width of 1936 and a height of 1048 pixels.
I found the object in 5 locations:
[ { x = 1689, y = 548 }, { x = 1400, y = 519 }, { x = 1375, y = 392 }, { x = 1212, y = 425 }, { x = 1081, y = 1013 } ]
Waiting for task to complete.

I work in the window with title ‘Elvenar - Fantasy City Builder Game - Google Chrome’.
Operate bot:
The last screenshot had a width of 1936 and a height of 1048 pixels.
I found the object in 4 locations:
[ { x = 1400, y = 519 }, { x = 1375, y = 392 }, { x = 1212, y = 425 }, { x = 1081, y = 1013 } ]
Waiting for task to complete.

I noticed the bot is using between 30-60% cpu and 1.7GB ram, so it’s very busy doing nothing or stuck in a loop.

Thank you for the test.

Seeing these numbers, I will invest in reducing runtime expenses next. The image processing framework is new, and I see some low-hanging fruits that might reduce the expenses to a fraction. Maybe I get to implement this next week. We will then check the recording from your session for the missing matches.

1 Like

I found some time to work on Elvenar again in the last weeks. The result is some changes in the program that reduced the CPU and memory usage by two-thirds.
You can run the new version of the Elvenar bot from bots/implement/applications/elvenar/elvenar-bot at 9b775fc1ac92e5dabe8b89fc55965b4057ef70ce · Viir/bots · GitHub

I tried the bot, but it doesn’t works or doesn’t start
in the botlab window it comes

Get the next reading from the game
Taking the first reading from the window…
— Framework —

Waiting for 0 task(s) to complete:
2 task(s) from bot in queue
Stopped with result: Failed to create volatile process: System.Exception: Failed to setup the volatile process: System.Exception
—> Microsoft.CodeAnalysis.Scripting.CompilationErrorException: (177,8): error CS8983: Eine „Struktur“ mit Feldinitialisierern muss einen explizit deklarierten Konstruktor enthalten.
at Microsoft.CodeAnalysis.Scripting.ScriptBuilder.ThrowIfAnyCompilationErrors(DiagnosticBag diagnostics, DiagnosticFormatter formatter)
at Microsoft.CodeAnalysis.Scripting.ScriptBuilder.CreateExecutor[T](ScriptCompiler compiler, Compilation compilation, Boolean emitDebugInformation, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Scripting.Script1.GetExecutor(CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Scripting.Script1.RunAsync(Object globals, Func2 catchException, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Scripting.Script1.RunAsync(Object globals, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScript.RunAsync[T](String code, ScriptOptions options, Object globals, Type globalsType, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScript.RunAsync(String code, ScriptOptions options, Object globals, Type globalsType, CancellationToken cancellationToken)
at BotLabClient.VolatileProcess.RunScript(String script)
— End of inner exception stack trace —
at BotLabClient.VolatileProcess…ctor(Func`2 getFileFromHashSHA256, String csharpScriptCode, Object scriptGlobals)
at BotLab.Client.PlaySession.PerformAgentTask(StartTask startTask)

Welcome Sascha :wave:
I see the bot I linked in June in the post above does not work with the latest BotLab client, following a change in the C# compiler.

The solution is to use this newer version of the Elvenar bot: https://github.com/Viir/bots/tree/2d6790a184cee253e402499489b7e1be1b5818c4/implement/applications/elvenar/elvenar-bot

This one works normally also with BotLab client version 2022-10-07.

The status text from the bot then looks like this:

Wait before starting next reading...
Last reading from window: window.width = 880, window.height = 774, windowClientArea.width = 862, windowClientArea.height = 765, observed = 0, 0, 878, 772
Pixels: 170280 binned 2x2, 19992 original.
I found the coin in 3 locations:
[ { x = 415, y = 452 }, { x = 403, y = 323 }, { x = 173, y = 328 } ]
--- Framework ---
I work in the window with title '2022-03-07-elvenar-djvj-BTqe1xf.bmp - Paint'.
Waiting for 0 task(s) to complete: 
0 task(s) from bot in queue
Operate bot

This week I made a new version of the Elvenar bot. It is now easier to use and more robust when locating in-game objects like, for example, the coins to collect.

I started a new thread to track the development of the Elvenar bot at https://forum.botlab.org/t/elvenar-bot/4645

I will update that thread when new features arrive. Support for workshops and aggregating performance metrics/collection counters will probably be next.

Besides the thread on the forum, this is a direct permalink to the guide updated along with the bot itself: https://to.botlab.org/guide/app/elvenar-bot

Hello and thank you for all the effort i would like to ask if there is any update on this project i tried using the botlab and im getting this error
Failed building JavaScript on retry: Failed compiling the bot program code: in file src/Backend/InterfaceToHost_Root.elm: Unknown bot interface version ID: ‘20210823’. This compiler only supports the following 2 versions: 2023_02_06, 2023_05_15
i think it means that it is outdated, anything we could do ?
Thank you again in advance have a nice day :slight_smile:

Welcome Teo :wave:

Yes, that error message indicates that you found some link to a bot that is outdated.

There is a newer version of the Elvenar bot: 3e28ced601b84b5c.
This one works with the latest interface version:
https://catalog.botlab.org/3e28ced601b84b5c

image

(The permanent link that is updated with new releases is this one: https://to.botlab.org/guide/app/elvenar-bot)

1 Like