Testing Bots

For AI and campaign script related discussions and questions
Post Reply
Volzotan Smeik
New user
Posts: 1
Joined: 21 Oct 2022, 18:17

Testing Bots

Post by Volzotan Smeik »

Hi there!

I am new to WZ development, but experienced in development, Javascript and linux. I am trying to play around with AI development. Specifically, I am trying to find a way to automatically instantiate AI-only matches. First, via the Wiki, I arrived at https://developer.wz2100.net/wiki/AiTutorial, which seems outdated to me.
Then, via google, I found viewtopic.php?t=12873, which brought me to the command options "--skirmish=<mytestfile.json> --autogame". Using the file "data/mp/tests/highground.json", I managed to start an autogame. However, the players don't seem to be controlled by the AI defined in the file, I believe only the scavengers are actually doing something. Plus, the game runs at infinite speed, which prevents me from seeing what the AIs are doing.
Then, I asked on discord, where I got the answer "open the debug menu and attach one to the player". After some searching, I found "SHIFT + BACKSPACE => DEBUG MODE" and "CTRL + O => Open Menu" and finally managed to instantiate an AI-only match.

However, doing this manually is an awful lot of keystrokes if I want to play around with my own AI and see how its character changes every few minutes. How are you doing this? I am still looking for a way to automatically start such a game (obviously, in variable speed) from the command line. If I save the game after attaching an AI to my player, the AI is no longer attached after reloading it manually or using "--loadskirmish" (I am getting error messages on the command line like "[findInstanceForPlayer:732] Script context for player 0 and script name bonecrusher not found"). Fiddling around with the saved file didn't work.

Any hints anybody?
User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 938
Joined: 26 Sep 2016, 19:56

Re: Testing Bots

Post by Berserk Cyborg »

Attaching via the debug menu is the way to go for examining bot behavior. You won't need to save anyway (it won't work as you found out). I usually set the speed to 10x or 20x when I test Cobra. Bigger maps with more AIs will be more stressful on a system and take longer so I usually limit myself to 6 player maps at most. You can get maps from either the addons section at this site or from here.

I rarely use autogames as I prefer to watch what the bot is doing as these are merely tests to quickly simulate a pure and fair match between bots or see if something broke.

There is no guide for making AIs so you'll just have to take a look at the others. SemperFi is the most simple AI and one of the strongest against other bots 1v1. Though feel free to look at the API docs and such (especially Scripting.md): https://github.com/Warzone2100/warzone2 ... master/doc.
User avatar
Tzeentch
Trained
Trained
Posts: 315
Joined: 14 Oct 2012, 14:24

Re: Testing Bots

Post by Tzeentch »

It would be good to provide a saved file that loads up an autogame and sets the speed so an AI bot change can be made, then tested with a one-liner fairly quickly to iterate over a bunch of maps. Though being fair, it can be tested quite quickly as is with a oneliner like this:

warzone2100 --skirmish=test (even if complains about no test file, it loads into the game menus)

I haven't quite seen where a file exists to provide a kind of example, as that would be handy to include in a readme for AI bot testing.
Ideally going straight into spectator mode, thereby seeing the stats during play too!
Even some logic to dynamically adjust speed i.e. in combat x3, no combat x10... for eg. or other small things can be nice.
I want to test an AI bot I'm working by having at least 3 if not 4 instances running each on different difficulty settings to make quick global assessments.

Each of the bots with the one exception has features/qualities the others don't posses in some instances, so they're all useful as a template for ideas at the very least, though the code is rather different in style but certainly it all helps out.

The great thing about the JS aspect is you can make frequent minor changes and test very quickly.
Whomever ported code from what I hear of what was WZ scripting code into JS I'm very grateful for.
Post Reply