Jump to content


Photo

Automation features and discussion

automation

13 replies to this topic

#1 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1406 posts

Posted 12 January 2019 - 04:12 AM

*
POPULAR

I have previously posted about automation efforts in this thread about watching over asset files.

I decided to create a more generic thread for whatever discussions related to automation.

 

The most recent version of automation library and scripts (by the time this topic was created) can be downloaded from this link.

More information can be found in readme.md.

It should run properly against any beta version of TDM 2.07.

 

Some new Python 3 is required to run automation stuff.

I'm afraid that decent skills in Python are needed if you want to do anything advanced with it.

If you have some tedious work that you regularly do with TDM, and feel that it can be automated, post ideas here.


  • STiFU, freyk, Anderson and 2 others like this

#2 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1406 posts

Posted 12 January 2019 - 04:15 AM

Here is a video showcasing automation commands (you can type them into console.py, and I intend to integrate them into automation library in future).

I managed to complete the shortest TDM mission without directly interacting with the game.

 

Beware: the video is long and very boring :mellow:

 


  • RPGista, freyk, Anderson and 1 other like this

#3 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1406 posts

Posted 12 January 2019 - 04:21 AM

Just now automation has been used to start every FM released to date.

It is about 125-128 missions already :o

That's a huge number :wub: , and merely starting and cheat-completing them all takes something like 90 minutes :wacko:

 

If anyone is interested in this feature, see complete_any.seq (commands sequence) and foreachfm.py (the runner script) in the automation package.


  • Anderson and Abusimplea like this

#4 Abusimplea

Abusimplea

    Advanced Member

  • Member
  • PipPipPip
  • 515 posts

Posted 12 January 2019 - 05:16 AM

That changes everything - hardcore ghosters will have to play the game without a mouse using your remote to get any satisfaction now. :P


  • nbohr1more likes this

#5 freyk

freyk

    Advanced Member

  • Member
  • PipPipPip
  • 732 posts

Posted 12 January 2019 - 05:50 AM

At this moment, i can only say to this automation feature: WOW! :blink:
Immediately got some ideas for it. Like a TDM-Tweaker, video-problems debugger, benchmarker, etc.
 
Now to find a small python collection package (or one-single binary), to run scripts from. 
Do you know something i can use.
Like winpython?
 
 
Btw,
nice to see midnight commander in action.
I'm a bit more a totalcommander (ultima prime) user myself.

Edited by freyk, 12 January 2019 - 06:12 AM.


#6 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3511 posts

Posted 12 January 2019 - 07:25 AM

So, who is going to train a deep neural network now to play tdm with this? ;-)

#7 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1406 posts

Posted 12 January 2019 - 10:10 AM

Now to find a small python collection package (or one-single binary), to run scripts from. 
Do you know something i can use.
Like winpython?

Never used anything except CPython myself.

People use py2exe or pyinstaller to produce a standalone executable.

I'll try them in future (after I get rid of ugly sys.path hack).
 
 

nice to see midnight commander in action.
I'm a bit more a totalcommander (ultima prime) user myself.

Thou shalt not confuse the great Far Manager with the ugly Midnight Commander!

Anyway, all of them are descendants of the same Norton Commander.



#8 jaxa

jaxa

    Advanced Member

  • Member
  • PipPipPip
  • 1377 posts

Posted 12 January 2019 - 11:29 AM

Automation should be used to create missions, not play them! Like Swift Mazes but more advanced...



#9 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3511 posts

Posted 13 January 2019 - 04:56 AM

I figured, I'll use automation for testing if my fix for #4952 works. :-)

I have added two new commandline args "num_repeats" and "repeat_seqFile" to foreachfm.py. If both are specified, the regular seqFile is only executed once as a form of initialization and then repeat_seqFile is executed periodically as specified in the num_repeats argument.

 

This way, I can now easily repeatedly enter the fighting area and let myself get killed by the AI with a simple a script as this:

#teleport to fighting area, wait to be killed

setviewpos -551.59 -1949.04 -180.94 -16.0 -176.5 1.1

$time.sleep(20.0)

This is really awesome and makes our lives a lot easier, so thanks stgatilov!! :-) I have the debugger attached. If I eventually hit a set breakpoint, my fix works! :-) If the game crashes, it doesn't. ^^

 

By the way, I accidentally once tele-fragged the AI because I had used a too low sleep timing. :-D



#10 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3511 posts

Posted 13 January 2019 - 06:09 AM

Ok, so far, I didn't manage to reproduce the behavior with this sequence. So I was thinking to add random rotations and movements as well as the occasional attack. So, how to feed random values from python to the automation interface? One way to achieve this would be to have python write a new .seq file with the desired commands and have that .seq file executed. I guess, there is no other interface to achieve that right now, is there?



#11 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3511 posts

Posted 13 January 2019 - 07:42 AM

After three hours of running, the game crashed in Automation::ParseAction() with a Null-pointer exception because 

idFile *f = fileSystem->OpenFileRead(logFile->GetName());

apparently failed to open the file for some reason and f==NULL is not asserted. I wonder why it cannot open the file anymore. I backuped the pdb and saved both a full dump and a minidump, if you want to investigate the issue closer. The full dump is 5 gigs, though.

 

This is not the crash I was hoping for... If it had crashed during LeaveSearch() again, I would've known that my fix does not work. Now, as it stands, I haven't learnt anything, except that this is maybe the wrong way to reproduce the issue or that it is incredibly rare!

 

Callstack:

TheDarkModx64.exe!idCommonLocal::GetConsoleContents(int begin=31058, int end=31058) Line 502 C++
TheDarkModx64.exe!Automation::ParseAction(Automation::ParseIn & parseIn={...}) Line 298 C++
TheDarkModx64.exe!Automation::ParseMessage(Automation::ParseIn & parseIn={...}) Line 269 C++
TheDarkModx64.exe!Automation::ParseMessage(const char * message=0x00000232c0554cb0, int len=107) Line 256 C++
TheDarkModx64.exe!Automation::Think() Line 533 C++
TheDarkModx64.exe!Auto_Think() Line 538 C++
TheDarkModx64.exe!idEventLoop::RunEventLoop(bool commandExecution=true) Line 171 C++
TheDarkModx64.exe!idCommonLocal::Frame() Line 2450 C++
TheDarkModx64.exe!WinMain(HINSTANCE__ * hInstance=0x00007ff7e4f40000, HINSTANCE__ * hPrevInstance=0x0000000000000000, char * lpCmdLine=0x00000232df913bbe, int nCmdShow=10) Line 1363 C++


#12 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1406 posts

Posted 16 January 2019 - 10:36 AM

I figured, I'll use automation for testing if my fix for #4952 works. :-)
I have added two new commandline args "num_repeats" and "repeat_seqFile" to foreachfm.py. If both are specified, the regular seqFile is only executed once as a form of initialization and then repeat_seqFile is executed periodically as specified in the num_repeats argument.

To be honest, I hoped that script will only be used for massive testing over many FMs, not for ordinary checking.

Probably it's better to keep it that way, because otherwise a lot of stuff will fill it over time.

 

There is another script called repeat.py, which is very small and not really important.

It's better to fill it with regular testing stuff.

For instance, I used it for testing crashes in 4919 the following hacky way:

1) I created a file finish_mission.seq, which loads a quicksave, moves forward to mission exit, waits until mission finish screen loads up.

2) Then I created another file finish_mission_10.seq, which had one command @file finish_mission.seq copy-pasted 10 times, and exit at the very end.

3) Then I run repeat.py finish_mission_10.seq.

So it boots TDM, performs sequence 10 times in a row, then properly exits. Repeat 100 times. If something crashes, repeat.py will catch nonzero exit code.



#13 stgatilov

stgatilov

    Lead Programmer

  • Active Developer
  • PipPipPip
  • 1406 posts

Posted 16 January 2019 - 10:52 AM

Ok, so far, I didn't manage to reproduce the behavior with this sequence. So I was thinking to add random rotations and movements as well as the occasional attack. So, how to feed random values from python to the automation interface? One way to achieve this would be to have python write a new .seq file with the desired commands and have that .seq file executed. I guess, there is no other interface to achieve that right now, is there?

There is no plan to turn automation commands syntax into real programming language --- there is python for that!

Just write your own Python script and use automation class there directly.

For gameplay actions you can either try to use game_controls directly or try to invoke console.py (I seriously plan to move commands execution engine from this script to library).

 

After three hours of running, the game crashed in Automation::ParseAction() with a Null-pointer exception because 

idFile *f = fileSystem->OpenFileRead(logFile->GetName());

apparently failed to open the file for some reason and f==NULL is not asserted. I wonder why it cannot open the file anymore. I backuped the pdb and saved both a full dump and a minidump, if you want to investigate the issue closer. The full dump is 5 gigs, though.

This is not the crash I was hoping for... If it had crashed during LeaveSearch() again, I would've known that my fix does not work. Now, as it stands, I haven't learnt anything, except that this is maybe the wrong way to reproduce the issue or that it is incredibly rare!

Did you look for this file on your machine? Was it present or not? empty or not?

When did this happened? Does your script rerun TDM process? install different FM?

Do you normally have logFile cvar enabled?

 

This may be some sort of race condition.



#14 STiFU

STiFU

    Uber member

  • Development Role
  • PipPipPipPip
  • 3511 posts

Posted 16 January 2019 - 01:39 PM

Wowza, I expected you'd be happy about somebody actually using your automation stuff. ^^
 

To be honest, I hoped that script will only be used for massive testing over many FMs, not for ordinary checking.
Probably it's better to keep it that way, because otherwise a lot of stuff will fill it over time.

Well, that script already supported testing individual FMs. And using a repeatable .seq file might also make sense with massive FM testing. With that in place, you can very easily, without even knowing python, test about anything, and that's good right? I really see no harm in adding that feature, but if you don't like it, we can very well revert the change and I'll add a renamed copy of it. But look at the diff first. It's really almost nothing I have added. ;)
 

Just write your own Python script and use automation class there directly.
For gameplay actions you can either try to use game_controls directly or try to invoke console.py (I seriously plan to move commands execution engine from this script to library).

Could you show me an example of howto do a random rotation in tdm with a python script? I tried to figure it out, but I am not that experienced with python and I also miss all those comfort features of Visual Studio. :-)
 

Did you look for this file on your machine? Was it present or not? empty or not?
When did this happened? Does your script rerun TDM process? install different FM?
Do you normally have logFile cvar enabled?

It was present and filled, if happened after 3 hours of "fighting" in the Training Mission using the described automation script. It does not restart TDM process inbetween, just 3 hours of continuous testing in a single FM without any reloading. I have logfile 2 always set.



Reply to this topic



  



Also tagged with one or more of these keywords: automation

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users