SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.72k stars 1.12k forks source link

Headless mode #652

Open coffenbacher opened 7 years ago

coffenbacher commented 7 years ago

I would love to be able to develop and run tests of the engine without spinning up the whole asset loading & graphics pipeline. Combining a simple test framework with the history / log discussed in Chipmunk's pull request this could enable powerful regression testing as well in the future.

For example, in some silly pseudocode, maybe testing wood gathering could look like this:

# test_wood_gatherer_log.txt:
- tick 0: load TestArabia.map
- tick 0: spawn villager at (1,1) with id 0
- tick 1: task unit with id 0 to chop wood at (1,2)
- tick 1000: end

# test.py
import headless_engine
headless_engine.run(open('test_wood_gatherer_log.txt'))
assert headless_engine.get(unit=0)['carrying']['wood'] == 10

Perhaps this is already possible. If so, can someone point me in the right direction for doing so?

(This is a bit of a stupid reason / test compared to the architectural advantages of a headless mode, but I only develop on Linux over SSH (my local machine cannot effectively run it) and I'd love to be able to contribute without having access to Linux with a graphical environment. Except for the rendering pipeline, everything should be workable like that it seems.)

TheJJ commented 7 years ago

Jup, should be a very good thing especially for automated testing gameplay features.

VelorumS commented 7 years ago

We'll be getting the game logic out of the client (while still using it somehow for the prediction). So the test you've described will be for the server code.

The different kind of test will be needed for the client part that plays the history. Because the history is what has been recorded after the execution of the game logic. For example, path finding is done on the server, so the history contains only a "rasterized" path.

Actually, I was thinking about the fastest way to see the multiplayer in action. While playing the game, make the client dump curves (in whatever form they are available) to stdout, pipe that to the second client that will be reproducing the game. It involves some shims "before" and "after" the game logic calculations, but no explicit headless launch...

coffenbacher commented 7 years ago

Can we also just send the curves over loopback IP instead of stdout so it's consistent with needing a network stack?

Also, I got a little lost, where is the server code in your 3rd paragraph?

VelorumS commented 7 years ago

over loopback IP

It's faster to just std::cout than edit cmake to get the boost::asio/or-whatever working. Besides, network junkies haven't decided on the protocol yet, so it's temporary.

Also, I got a little lost, where is the server code in your 3rd paragraph?

We already have the server code on the client - it's the game logic. Now we need to record history and write it out.

coffenbacher commented 7 years ago

Cool, got it.