Bot script utils: compiler and decompiler

Discuss all aspects related to modding Zandronum here.
Post Reply
Const
New User
Posts: 7
Joined: Mon Jun 04, 2018 8:31 pm
Contact:

Bot script utils: compiler and decompiler

#1

Post by Const » Thu May 07, 2020 8:27 pm

Hi.
I've updated bot utils to a more or less stable state. Now I want to release them for you to test and use.
Ok, seriously. To speak frankly, as this kinda first official release, so there are probably bugs and you might not be able to run them. Let me know about such issues, so I can fix them.

Kudos to @sleepy for fixing some issues, filing bugs in the repos and thus inspiring me to continue these projects.

botc - bot script compiler
This project is a continuation of @CrimsonDusks botc compiler. Some bugs are fixed, some features are added, namely:
  • unused return values should not lead to stack overflows in Zandronum
  • variable limits should be fixed now, so variables defined in one state should not count to limits for variables in another state
  • added support for arrayset function
  • switch-case blocks now support negative numbers
  • fixed some crashes
  • it should be easier to build botc compiler from sources yourself, at least if you use Windows or Ubuntu and CLang/LLVM
Plans:
  • boolean as a real type different from ints - if-block conditions will have to be truly boolean like in Java
  • support contants in switch-case
  • support else if
  • define variables without '$'
  • support return
  • add some examples
You run it from terminal/cmd.exe like this:

Code: Select all

botc script.botc BOTLUMP
After that you can replace existing compiled bot lumps with BOTLUMP file.
(You might need to install Microsoft VC++ runtime files (on Windows) or libc++-9 and libc++abi-9 (on Ubuntu))

Currently the best way to get some examples is to decompile lumps (with debotc) from Zandronum pk3 file.

Download
Source code
Some what obsolete examples: CRASHBOT, HUMANBOT
Spoiler: debotc - bot bytecode decompiler (Open)
This is a tool to decompile bot bytecode files from Zandronum (and probably ST too) to scripts compatible with botc.
It is written in Kotlin and compiled to binaries with LLVM, so you might need the same libraries as above + something LLVM or MingW specific. I can build .jar-s (binaries for Java 8 Runtime) if someone prefers that.

Known bugs:
  • You need to manually uncomment Roam calls and other calls with unused return values (it's only Roam for stock Zandronum bots)
You run it from terminal/cmd.exe like this:

Code: Select all

debotc BOTLUMP script.botc
after that you can open script.botc in your favourite code editor.

Plans:
  • Fix the need to manually uncomment Roam(100) lines
  • Less redundant code in some cases (like if-else with else actually not needed)
Download
Source code
Last edited by Const on Fri May 08, 2020 10:53 pm, edited 1 time in total.

sleep
New User
Posts: 6
Joined: Wed Mar 25, 2020 10:05 pm

Re: Bot script utils: compiler and decompiler

#2

Post by sleep » Fri May 08, 2020 3:13 am

Thank you for posting this, I was anxious to see the day this would be released. Bots can be made a little smarter by commenting all calls to delay() in the decompiled source, that will make them never stop to chat, something I had real issue with, in fact, the decompiled sources are attached in this ticket <https://zandronum.com/tracker/view.php?id=3775>. This should allow development for bots to other game modes such as cooperative and capture the flag, huge challenge but the possibility is finally here.

Const
New User
Posts: 7
Joined: Mon Jun 04, 2018 8:31 pm
Contact:

Re: Bot script utils: compiler and decompiler

#3

Post by Const » Fri May 08, 2020 10:20 pm

I'm afraid supporting new modes, especially cooperative ones, would require changes to Zandronum itself. For example current bots VM implementation doesn't allow targeting monsters (they are not counted as enemies) nor provide an easy way to do pathfinding to an enemy flag.
Actually, now that we can recompile stock bots, I would argue for a complete refactor/rehaul of the bots VM. Unfortunately I don't have time now to work on that. But I'll try to help with it if anybody wants to give it a try.
Or, as a quick fix, it probably makes sense to replace ACS_Execute in bots VM with ACS_ExecuteWithResult. That will enable some meaningful interaction with ACS.

Post Reply