I am trying to automatically simulate the game experience in my programming game. I think Expect is the way to do it because it creates its own tty for the process, becoming independent process of the main process but I want that some key sequence is pressed down in some pattern, such as press the key Z down every minute or press this that with this that pauses, without really expecting any specific file descriptors. Is there some ready programs to automate this kind of high-level debugging?

I have access to obsd and ubuntu.

  • \$\begingroup\$ Related: gaming.stackexchange.com/questions/21167/… \$\endgroup\$ – Ragnar Apr 28 '11 at 14:26
  • \$\begingroup\$ It's basically the same question, just worded differently, so as to circumvent the rules that prevented gaming.SE from answering the question. Personally, I have no problem with the question here, it does not break any rules, it's just that it's similar (in, how can I put this... meaning? I think, but that might not be the correct term) to the previous one. They are related insofar that they refer to the same basic functionality of the program you want to build and use (pressing the same key or sequence of keys every minute or so). They are similar questions, no matter how you put it. \$\endgroup\$ – Ragnar Apr 28 '11 at 14:33
  • 1
    \$\begingroup\$ That's a related question, but useless answer in this context. The answer given there was that it violates the rules of the game, which is a helpful answer for a player but useless for a developer. Now, since he asked both questions it seems likely this is a veiled attempt to con us into helping him cheat, but that's a separate issue. \$\endgroup\$ – jhocking Apr 28 '11 at 14:34
  • \$\begingroup\$ @jhocking - I linked to the question, not an answer... \$\endgroup\$ – Ragnar Apr 28 '11 at 14:36

There are ways to do the high level testing, but I'll throw in my 2 cents about this approach first! I think if you instead implement unit testing on each aspect of your game, it would be a better test. If you make some test that runs whatever function is called when you input that key sequence, just provide the unit test with all key sequences that you think might break the function. If it works for all key sequences, then you know the internals for that function are good and you can go on to test the link between the input box and that function. That test is easier and you only need to make sure the data gets passed to the function. After all of that works, then the testing above that is usually done by play testers, or in your case you. The top level test would need to be done either way.

Now, to answer your question, before I knew what unit testing was, I used something called workspace macro recorder to do exactly what you're asking. Given, your program may need some sort of testing that I'm not thinking of, but if your program fits in the general scope that I'm thinking, my previous approach should be more helpful.

  • \$\begingroup\$ blah, just read the other post, you're hacking a game, oh well. just use workspace macro \$\endgroup\$ – brandon Apr 28 '11 at 14:33

In short game event logging and replay is how you automate this. I don't know of any 3rd party software that does this (qualifier: SDK to integrate into app), but doing it yourself is both really easy and perhaps really hard.

You use game events to mean stuff like "pressed the X key" or "moved the mouse by (10,2)"

You play the game once recording each keystroke/mouse movement and the precise time it occured relative to the start of the recording. Once you are finished recording, you run the program again, but instead of generating the events from the mouse/keyboard, you simply play back the events you recorded, in order, at the right time. So, say if you found a reproducible bug that takes a few minutes of running around waving a sword or jumping into a wall, then you can record all of your actions and replay them again and see if you get the same results (if you have a deterministic engine, you should). Then you can make fixes, play it back again, etc. until the bug is fixed.

Though it isn't the same purpose, you've probably seen this method in old arcade games ('demo mode' before you insert a coin). It would have been too expensive to simply record a fullscreen demo to playback when the machines have < 1024KB of RAM, so the they record the actions and play them back as a sort of "real-time video" or "compression".

Getting the game/engine to be deterministic is a lot harder though.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy