Jump to content

Towards Automated Testing


Recommended Posts

Here is a Python 0AD launcher which intercepts stdout lines and reacts to certain command. The commands start with hash bang space '#! '. They can be placed everywhere (I think) within JS code.

Example:

print("#! terminate"); // terminates 0AD

Currently it works with Python 2.6.7 (Ubuntu 14.04 default) and gnome-terminal and probably a lot of other configurations. So far it understands 3 commands:

print("#! write Full/File/Path") // opens a file to redirect outputprint("#! close")                // closes this fileprint("#! terminate")            // terminates 0ADprint("#! clear");               // clears terminal, not yet working

It's already in use to export the triple store as JSON file. Next steps will be output to multiple files and overwrite files within a bot directory e.g. to relaunch with a different config and somehow marry it with the charts mod.

Most pressing question now is: How can I call 'Engine.SetSimRate(20)' from JS or the launcher?

I'm not exactly an expert in system programming with Python, but the links of the copy&pasted code are included. Feel free to propose more commands, I'll check everything.

launcher.py.zip

Link to comment
Share on other sites

No, it's not for game testing, it's for bot testing. I need a possibility to tryout different strategies and don't have the time to actually play them interactively. Imagine it as a very little step towards introducing bots based on Monte Carlo methods or genetic algorithms. There is of course some overlapping - no offense meant here.

Engine.SetSimRate(20), anyone?

Edited by agentx
Link to comment
Share on other sites

The launcher can now deal with xdotool on Linux. xdotool can move windows, sends keystrokes and mouse clicks, works quite reliable. Also I found glc allows to capture OpenGL windows. Launcher.py is now at github. Here a video showing why this toolchain was needed. It shows Hannibal launching two miner groups and a scout. At tick #10 it switches to SimRate 20.

It took some time to make the video caps running, so here the script to save anybody else interested some headache:

## launch 0 A.D. per python script with autostart captureglc-capture --start --fps=30 --resize=1.0 --disable-audio --out=pyro.glc ./launcher.py## convert captured byte stream into mp4glc-play pyro.glc -o - -y 1 | avconv  -i -  -an -y pyro.mp4## remove 15 secs with black frames at startavconv -i pyro.mp4 -codec copy -ss 15 -y pyro01.mp4## move mp4 header from end to start for better streamingqt-faststart pyro01.mp4 pyro02.mp4## checkmplayer pyro02.mp4
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...