Answer the question
In order to leave comments, you need to log in
What patterns to use for game bots?
Good afternoon, dear Tostorians.
I turn to you for advice on how to write game bots in order to have the cleanest possible code. I want to write in js, but this is not the point. The game StarCraft 2, although it doesn’t matter, the writing process is no different from any browser game, for example
What are the features of game bot building: the global context of the game - open data is stored there, for example, available resources, a list of your buildings, workers and warriors. In addition to the context, there is also an infinite loop.
The main problem is that every time the compiler enters this infinite loop, it has to redefine the current stage of the game. To do this, I add a global variable for the current step and in a switch / case loop with a bunch of branches.
And if there can be two strategies at the same time, then the global list of active steps with the isActive flags.
It all looks extremely sad and I would like to figure out for academic purposes how to write such things correctly. Just tips and pieces of code are accepted)
Thank you for your attention
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question