My Notes, Quickstart + Getting Javascript bot to work

Good Evening,

I thought id pop in and just leave some notes, based on the chats here and my own tinkerings…

A) Getting My Engine to work,
I installed the dot net thing from this place:

I also have microsoft visual studio 2022 community edition installed, unsure if it helps

Everything happens from inside: 2024-Sproutopia-2024.0.1’s root folder,

I created startengine.bat:
@echo off
cd Sproutopia
dotnet run Sproutopia.csproj

This launches the engine, When the Engine is open, it waits for the next binding

B) The Visualiser
I created a second bat file, called startvisualiser.bat

@echo off
cd Visualiser
dotnet run visualiser.csproj

This opens the visualiser, which seems to run the game in real time

C) Java Script Bot (Could work for any)
I already have node installed from last year, you might want to install it if required.

I created a new folder called JSBOT inside
Then I copied the content of starterbot → JSBot into this new folder,
I also moved the contents of SRC into root and deleted src itself (This might not be needed),

Then I generated the Node Dependencies using npm i directly in the bot’s root folder,
Leaving me with:

Back in
2024-Sproutopia-2024.0.1’s root folder

I created another bat file runbot.bat containing:
cd ./JSBOT/
node index.js
pause

Opening this while the engine is running queues a bot up,
I changed my appsettings to run 4 bots from the get go.
So I run this bat 4 times,

If everything went well you can then run a game by opening the engine, visualizer and number of bots, :
And it looks something like:

Thats 6 command windows, 1 for the engine, one for the visualiser and one for each bot.

D) JS Bot Broken initially + Fix
My starterBot did not work immediately, I got an error:

“Error connecting: Error: Failed to invoke ‘Register’ due to an error on the server. InvalidDataException: Error binding arguments. Make sure that the types of the provided values match the types of the hub method being invoked.”

This has been an issue that I have had for the last 3 years, I have not looked at fixing it,
It could very well be environment.
But what I did do to resolve the issue is update the token generation from:

const token = process.env.Token ?? process.env.REGISTRATION_TOKEN;
to
const token = process.env[“REGISTRATION_TOKEN”] ?? createGuid();

and added a function:
function createGuid () {
return “xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx”.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c === “x” ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}

That manually generates a Token, cause the original function fails for me,
Thats the issues I experienced, as well as the fix (That I have been carting along for the last 3 years.

Maybe this helps some people get started, or deal with that annoying JavaScript Bot Bug.

Thats my whole setup, From Here, Its AI time…

6 Likes

Thanks for the detailed instructions Willie!! :star_struck: I’m sure it will help out some people who are unfamiliar with C#. The dockerfile has also now been included so hopefully, it can be a quicker setup, but I personally think it is more fun to see what the code is up to :joy:

Just one thing I want to point out. Though it is technically fine for you to add a random token(Guid) to the bot. We would prefer that you generate the GUID elsewhere maybe using a tool like : Free Online GUID Generator and then inject the token via an environment variable.

The reasoning for this is that; for the tournaments to run, we run your bots and inject the tokens using the environment variables. So the bot would be unable to run in a tournament if you generated your token internally.

Sorry, it’s been an issue that you’ve experienced for so long. I hope this clears things up! We will add something to the readme to help other players get started as well :blush:

I only generate the token if the normal functions fail,

So its very possible that it generates them properly on the server,

I will try and fix it,
My Dev machine does not like those variables a lot.

Thank you for the heads up,
**Sidenote, I have not had any issues with this yet

Making me believe that the token generation works fine on your side.
I will alter it a bit more to only generate GUID if it failed with the normal code.
Thats likely why we never had issues in the past,

My Final entry for 2023 and 2022 both contained this method of GUID generation :grin:

1 Like

Awsome! if it worked in the tournaments before then it should be fine to add :blush:

Strange that the env variables are failing sometimes :thinking: I’ll also look into it!

Hi @Jenique ,

I don’t see a dockerfile in the 2024.0.1 windows starter pack?

Hi @japes

Soo sorry :hear_no_evil: will add it to the very next release!

Thank you for letting me know!