WITP AUTOMATED SCENARIO TESTING APPLICATION el lobo, March 2017 DISCLAMER This is not an official application and is not approved, authorized, sanctioned, nor recognized by Matrix Games nor any of its affiliates. This application is designed for scenario testing only and will not function as a game automation. el lobo nor anyone else is responsible for loss of data. Use at your own risk. WARNING This application has the ability to overwrite existing files. Precautions have been taken to prevent this. See the documentation below. SYNOPSIS This is a script to be installed in the program, autohotkey (AHK). AHK sits on top of witp-ae and fires E and Y as many times as the user sets. It does not interact with witp. As far as the app knows, it could be sitting on top of witp or tic-tac-toe. It is for research only and is useless for use in the game itself. The main purpose of the app is to be able to set-up your scenario and have it test automatically and create turn saves for your review. FEATURES The app can run and save as many turns as you desire, although it would probably not be useful running it past the end of the war. You can set your saves to start at any turn. For example, if you are testing something that you are going to run five-hundred turns, usually not much happens the first couple of hundred turns. You can set the saves to start at, say, three-hundred. You can set how often you would like to save, that is, every so many turns. I have found it most convenient to save the turns in the SAVE folder under which the scenario is running, so that they can be reviewed without having to make any file name changes. The saves start at wpae101.pws. The limitation is that you can only view ninety-nine of them (101 to 199) without having to change the names of the files. Ninety-nine is probably more than you want to review anyway. The tester can set the location of the saves as they desire. KNOWN ISSUES It can be run either as Japanese or Allied as Computer but has only been tested as Allied Computer. If you pause the application or the game, after you resume, most likely the game will remain stalled while the app keeps running. The app was not designed to run with multiple Turncycles nor has it been tested on multiple Turncycles. The app counters will not correspond to the game turns as they are set by the app and not the game. Although, the app should be able to run multiple Turncycles. Make sure the delay is set accordingly and divide all of the rest of the numbers by the Turncycle number. It is not known how this app will react if it and the game are being run in the background. The counters may not correspond exactly with the game turns but will be close. You may want to add an extra turn or two. By design, the turns are saved with file names starting at wpae101.pws, then, wpae102.pws, ..103.., etc. They are shown in witp's "SAVE GAME" screen in corresponding slot numbers. The saves may or may not correspond to turn numbers depending on how you set your saves. When you open the game and "Load a Saved Game," you will see the turns in the slot numbers starting at slot 101. Each turn will have the information: war date of the game turn, "Autosave," and no other information. Before re-testing the same scenario, End Game and start the scenario anew. If the app is running and the game is running, but you do not get the saves you want, check that whatever text editor you are using, Notepad, Word, OpenOffice Writer, etc. has not inserted a space in your paths. It happens once in awhile when they have to wrap test. INSTALLATION. Of AHK. This is a bit fuzzy for me as autohotkey has excellent documentation but lacks information on the simple stuff. The first page of their Tutorial describes how to download and install AHK. https://autohotkey.com/docs/Tutorial.htm video - https://autohotkey.com/board/topic/72446-video-tutorial-install-and-hello-world/ Download and install AHK. https://autohotkey.com/ I used Version 1.1.25.01 (listed as 1.1.*) with UNICODE Of the app. Scroll down to the bottom of this documentation to the Script and change you DOS paths as necessary. See "WARNING" below. Those experienced with DOS can skip reading the warning. Go to line 42 in the Script below and "comment" (;) the line below, and go to line 44 and change your DOS paths in the line below. The AHK Tutorial describes how to write your first script. Instead of writing a script, copy and paste the Script below, (after you have made any necessary changes,) into the AHK window. Be sure that it is saved with an .ahk extension. Once installed, double click the AHK desktop icon. You should get a little icon with an "H" in your system tray. The app should now be ready to run. RUNNING THE APP. Before running the app you need to manually time your scenario. See, "Enter the Delay in Seconds." below. Start your scenario as you usually do, Make sure the window is active by clicking a hex. Start the app by keying, ^w (hold CTRL and then hit "w") and you should get the following input screens. How many turns do you wish to run? Obvious. Enter the Delay in Seconds. (Should be about 20 +/-) This means, how long will it take from the time you End Orders until the Japanese (or Allied) "start screen," the same screen at which you are now looking, shows again? The app fires E, Y and then delays for the time that you set, and then fires E, Y again, etc. You should time this manually before you start the app to make sure you give it enough time delay. For example, on my computer, GA's Scenario #34 took a little less than twenty seconds to run from the time E, Y were fired and the time the Japanese screen showed again. I set the Delay at twenty-one seconds. To Save Turns: 0 = No Yes =1 If you select "0" (zero) for "No", the app will start right away. If you select "1" for "Yes", you will get the following input screens. After how many turns do you want to start Saving turns? Set 0 (zero) for no delay, IE. save Turn 1 For example, you may be R&Ding an a/c for five-hundred turns but you may not care what happens the first three-hundred or so turns, so you may want to set your saves to start around there. Note, you may want to add some extra turns to be sure to capture the last save. How many turns would you like the scenario to run until it Saves the next Turn? IE, save every turn (1), save every other turn (2), save every fifteenth turn (15), etc. Please do not enter zero. You had your chance to not save turns above and I don't know what will happen if you do set zero. Probably nothing but I am tested-out at the moment. If you selected to save turns, you will get a notification each time a turn is saved. They time-out so you do not need to do anything. After you make your choice, the app will start, fire, and will run until finished. You will get a notification when finished. You will know if the app is working if the game is running. If the game just sits there, the game is not receiving the E, Ys. If the app starts running but the game is not responding, or for any other reason, you can quit the app by right-clicking the H icon in the system tray and select Exit. WARNING ================== Program = War in the Pacific Admiral Edition.exe game = the game you play with the Program. Each time a game runs a turn, it saves the turn as wpae000.pws as an autosave. This is the file that is copied and renamed each time the app calls for a save. To where these files are copied is the problem as they will over-write any file with the same name. So, in the un-likely event that you are playing a game and testing your scenario using the same Program, the scenario testing could over-write your game. I could have had the app rename the game file saves to something that would not have been the same as the game saves that the Program uses. However this would require that the name be changed, for each file, every time the tester wants to review them. Too tedious. A lot of players run more than one Program on the same computer by copying the Program and renaming it. This creates a different DOS path and now each Program has its own path. For example, copying and changing: C:\Matrix Games\War in the Pacific Admiral's Edition\ to, C:\Matrix Games\War in the Pacific Admiral's Edition - PBEM-MyFriend\. One challenge was to decide how to put the user's Program path into the app. Since most witp scenario testers are above average in computer skills, the simplest way was to place witp's default paths in the app and the testers can change them. My biggest fear was that someone who is not familiar with DOS paths would run the app "just to see what happens," and in the process over-write some of their saved files. To prevent this, the app adds a folder, ScnTst, to your Save folder and if no changes are made, that is where the saves will be placed. Another precaution was to start the renaming of the save files at wpae101.pws as most users have their games saved in the lower numbers. You should change the DOS paths in the Scrip below to match your actual paths which you are using. You should comment-out (;) the line below Line 42 unless you want to keep that particular folder. Make the necessary changes. If you do not understand DOS paths, you probably should not run this app until you do. ;========= App Script Below, Make sure you get the last Bracket ========= SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #SingleInstance, Force ^w:: ; after turn is set, fire the program ; enter the number of turn cycles to run ----------------------------- InputBox, nt, Number of Turn Cycles, How many turns to you wish to run?,,200,,,,,, Sleep, 250 ;----------------------------- ; adjust delay between game turns ------------------- InputBox, dbt, Adjust the Delay Between Turns., Enter the Delay in Seconds. `n (Should be about 20 +/-),,200,,,,,, Sleep, 250 dbt := dbt*1000 ;----------------------------- ; Save Turns -- Y/N ----------------------------- InputBox, styn, Save Turns Yes/No?:, To Save Turns`: `n 0 = No`n 1 = Yes,,200,,,,,, Sleep, 250 if (styn = 0) { } else { InputBox, std,Save Turns Delay, After how many turns do you want to start Saving turns? `n`nSet 0 (zero) for no delay`, `nIE`, save Turn 1,,200,,,,,,0 Sleep, 250 InputBox, nbust,Turns Until Saves?, How many turns would you like the scenario to run until it Saves the next Turn ?`n`nPlease do not enter zero.,,200,,,,,,1 Sleep, 250 } i := 1 ; number of turns k := 1 ; how many turns between save turns m := 1 ; game save id counter StartTime := A_TickCount Loop, %nt% ; this is the start of the turns, running for the number of turn cycles set by nt { if (styn = 0) ; Save Turn Y/N, if false, styn 0, Save Turn will be not be activated, if styn = 1, will be { } else if (i < std) ; save turn delay start, set the number of turns before Save Turn begins, 0 for none, ie, save turn 1 { } else if (k = nbust) ; number until save turns, this will be the test for number of turns until saves { mC := m + 100 ; ---- Line 42, TESTERS, you may want to comment-out the following command ---- FileCreateDir, C:\Matrix Games\War in the Pacific Admiral's Edition\SAVE\ScnTst\ ; ---- Line 44, TESTERS, you will probably want to change the following paths ---- FileCopy, C:\Matrix Games\War in the Pacific Admiral's Edition\SAVE\wpae000.pws, C:\Matrix Games\War in the Pacific Admiral's Edition\SAVE\ScnTst\wpae%mC%.pws ; Copies a file into the same folder by providing a new name. Sleep, 2000 MsgBox, 64,Turn Saved ,Turn %i% Saved `n In slot %mC%, 1 ; a main feature of script Sleep, 2000 m++ k := 1 } else { k++ } ;MsgBox, FIRE %i% ; testing the loop if (i = 1) { Sleep, 1000 } SendInput, e Sleep, 1000 SendInput, y Sleep, dbt ; dbt, delay between turns if (i = nt) { nos := Round((A_TickCount - StartTime)/1000) Etime := FormatSeconds(nos) FormatSeconds(NumberOfSeconds) ; Convert the specified number of seconds to hh:mm:ss format. { time = 19990101 time += %NumberOfSeconds%, seconds FormatTime, mmss, %time%, mm:ss return NumberOfSeconds//3600 ":" mmss } MsgBox, ,WITP AUTO-SCEN, END:`n`n%i% Game Turns `n `nElapsed Time %Etime% } i++ } ; ======== App Script Above, Make sure you get that last Bracket =============