agentx Posted June 5, 2014 Report Share Posted June 5, 2014 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 0ADCurrently 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 workingIt'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 Quote Link to comment Share on other sites More sharing options...
Echelon9 Posted June 6, 2014 Report Share Posted June 6, 2014 Note there is already unit tests. Is that similar to the end goal you had in mind? Or were you thinking of in-place testing, rather than unit testing? Quote Link to comment Share on other sites More sharing options...
agentx Posted June 6, 2014 Author Report Share Posted June 6, 2014 (edited) 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 June 6, 2014 by agentx Quote Link to comment Share on other sites More sharing options...
Echelon9 Posted June 6, 2014 Report Share Posted June 6, 2014 Sounds great Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted June 6, 2014 Report Share Posted June 6, 2014 Engine.SetSimRate(20), anyone? Wait for triggers, then your maps can set the sim rate, and all you have to do is launch the maps. Quote Link to comment Share on other sites More sharing options...
agentx Posted June 6, 2014 Author Report Share Posted June 6, 2014 Can't wait, I'm already checking window remote control tools... Quote Link to comment Share on other sites More sharing options...
agentx Posted June 7, 2014 Author Report Share Posted June 7, 2014 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 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.