
Utilities, Controllers & Bots, Oh My!
Moderator: Shannon V. OKeets
Utilities, Controllers & Bots, Oh My!
...


- Attachments
-
- Slide1.jpg (65.99 KiB) Viewed 1717 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
I've been busy lately putting the game file editing concepts captured in https://www.matrixgames.com/forums/tm.asp?m=4136832 into code. Python code.
I've successfully built an initial (rudimentary) controller that can "safely" read-in, edit and save a MWiF game file. Examples of which I'll post later.
I also have plans to build several bots to automatically handle certain functions (e.g., allied ASW) based on pre-defined algorithms and rule sets. I hope to one day to even build AI modules to learn for an opponent, or opponents, and better execute these bots.
What you may ask do I mean by utilities, controllers, bots and AIs? Very good question and one which I plan to give you my thoughts on later.
I'm a bit tired right now and have some work to do to pull all this together for posting. So as a bit of a tease I'll leave it here for tonight with the promise of more posts with these details ... hopefully tomorrow.
[;)]
Now it's bedtime ... [>:]
I've successfully built an initial (rudimentary) controller that can "safely" read-in, edit and save a MWiF game file. Examples of which I'll post later.
I also have plans to build several bots to automatically handle certain functions (e.g., allied ASW) based on pre-defined algorithms and rule sets. I hope to one day to even build AI modules to learn for an opponent, or opponents, and better execute these bots.
What you may ask do I mean by utilities, controllers, bots and AIs? Very good question and one which I plan to give you my thoughts on later.
I'm a bit tired right now and have some work to do to pull all this together for posting. So as a bit of a tease I'll leave it here for tonight with the promise of more posts with these details ... hopefully tomorrow.
[;)]
Now it's bedtime ... [>:]
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
By the way, I wish to thank markb50k whose work on his World War III VERSION 2 mod has inspired me to move forward with putting game file editing concepts to code.
Thanks ... [8D]
Thanks ... [8D]
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
Before I go into specifics I wanted to layout my (initial) concept for a MWiF game file editing tool suite. My vision to say the least is grandiose and will require community participation to produce anything comprehensive in a reasonable period of time. If left to my own devices, my vision would take multiple decades to achieve. [8D]
At the core of my concept is the modification of MWiF game file(s) to achieve various goals, where modified game files remain compatible (i.e., work with) the MWiF game engine.
Though I've initially begun this in python, my vision is one that could/would incorporate computer executables and scripts from multiple languages and developers. However, one important constraint to this, for me at least, is that the end users (i.e., MWiF players) are not required to purchase anything beyond a license for MWiF to use the game file editing suite.
Utilities: This contains the functions, subroutines, methods and data to perform basic operations on the game file. For example, (1) open and save, (2) log changes, (3) flip/unflip units, (4) move counters, (5) change hex control, (6) change version, (7) keep ships/CPs at sea during RTB, (8) toggle "certain" optional rules, ... , (9999) etc.
Controllers: These allow the players to interface with the game file to either perform basic editing functions, run unit tests, integrate files from multiple (2-6) players, execute Bots and AIs to name just a few. Note that my vision includes two concepts for multi-player play. The traditional where up to 6 players play with each in command of a MP. The other is where players are given theater command that include two or more MPs.
Bots: These guys using deterministic rule sets and algorithms are designed to accomplish specific in-game missions/operations/functions. For example, (1) send out ASW escorts & patrols, (2) build convoy lines, (3) move a unit from point A to B changing hex control as applicable, (4) generate pre and post battle reports, (5) analyze various land, air and naval combat situations, ... , (9999) etc.
AIs: Like the Bots these guys are also designed to accomplish specific in-game missions/operations/function, but unlike the Bots learn to do it better over time.

At the core of my concept is the modification of MWiF game file(s) to achieve various goals, where modified game files remain compatible (i.e., work with) the MWiF game engine.
Though I've initially begun this in python, my vision is one that could/would incorporate computer executables and scripts from multiple languages and developers. However, one important constraint to this, for me at least, is that the end users (i.e., MWiF players) are not required to purchase anything beyond a license for MWiF to use the game file editing suite.
Utilities: This contains the functions, subroutines, methods and data to perform basic operations on the game file. For example, (1) open and save, (2) log changes, (3) flip/unflip units, (4) move counters, (5) change hex control, (6) change version, (7) keep ships/CPs at sea during RTB, (8) toggle "certain" optional rules, ... , (9999) etc.
Controllers: These allow the players to interface with the game file to either perform basic editing functions, run unit tests, integrate files from multiple (2-6) players, execute Bots and AIs to name just a few. Note that my vision includes two concepts for multi-player play. The traditional where up to 6 players play with each in command of a MP. The other is where players are given theater command that include two or more MPs.
Bots: These guys using deterministic rule sets and algorithms are designed to accomplish specific in-game missions/operations/functions. For example, (1) send out ASW escorts & patrols, (2) build convoy lines, (3) move a unit from point A to B changing hex control as applicable, (4) generate pre and post battle reports, (5) analyze various land, air and naval combat situations, ... , (9999) etc.
AIs: Like the Bots these guys are also designed to accomplish specific in-game missions/operations/function, but unlike the Bots learn to do it better over time.

- Attachments
-
- Slide2.jpg (192.26 KiB) Viewed 1716 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
I would also like to add that my concept for Bots include the functionality to implemented uncoded version 7 (FE) optional rules, version 8 (CE) rules, half-map scenarios and other scenario variants.
Should have all that done by tomorrow. [:D]
Should have all that done by tomorrow. [:D]
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
Ok, it's time for me to put some meat on the bones instead of just showing you pretty pictures. Technically I've only shown you one pretty picture so far. Well, I hope you think it was a pretty picture. [;)]
I've got a good start on putting many of the "manual" game file editing (gfe) techniques into python. I'm using object oriented programming to do this.

I've got a good start on putting many of the "manual" game file editing (gfe) techniques into python. I'm using object oriented programming to do this.

- Attachments
-
- Slide3.jpg (160.91 KiB) Viewed 1716 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
The first controller I've built (or am building), also using object oriented programming, is a unit test controller for the first MWIF utilities class (MWIF_Utilities_01.py) that's under development. To date, I've successfully executed 4 units, which I go into more detail and which will show the automated game file editing power of all this.
The second controller which I will soon begin will be a game file editor.

The second controller which I will soon begin will be a game file editor.

- Attachments
-
- Slide4.jpg (195.88 KiB) Viewed 1716 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
To date I've executed four unit tests on the MWIF_Utilities_01.py class. The beauty, or power, of using a controller to run these tests is that I can re-run past in addition to new unit tests on this class as it develops. Re-running past and comparing to previous units test runs will help minimize breakage as this class evolves (i.e., code additions and changes are made).
Below is the log file from the last executing of the unit test controller. I will in the following posts cover in more detail each of these unit tests.
UT.log
======================================================================================================
Unit Test: UT_001
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_001.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================
======================================================================================================
Unit Test: UT_002
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
Changed verison from 3.1.0.7 to 3.1.0.5
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_002.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================
======================================================================================================
Unit Test: UT_003
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Ita,Inf HQ,1934,0,Badoglio,0,60,
successfully moved counter from x,y= 60,42 to x,y= 61,52.
changed counter status to flipped and out-of-supply.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Italian,light aa,1939,0,20mm,0,60,
successfully moved counter from x,y= 60,42 to x,y= 61,52.
move_counters. ERROR. Unable to move and/or change counter status.
mc[country,type,year,id key,id,status,x,y]=
Italian,small aa,1939,0,20mm,0,60,
move_counters. ERROR. Unable to move and/or change counter status.
mc[country,type,year,id key,id,status,x,y]=
German,light aa,1939,0,20mm,0,60,
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
German,MIL,1936,0,LEIPZIG,99,56,
successfully moved counter from x,y= 56,27 to x,y= 61,52.
changed counter status to flipped and in-supply.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
UK,CVL,1913,0,eagle,99,46,
successfully moved counter from x,y= 46,26 to x,y= 38,22.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
NED,Convoy,1936,2,1,99,102,
successfully moved counter from x,y= 102,0 to x,y= 44,30.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Commonwealth,Oil,1936,2,2,99,47,
successfully moved counter from x,y= 47,26 to x,y= 42,26.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
German,u-boat,1939,1,4838,10,39,
successfully moved counter from x,y= 39,22 to x,y= 45,34.
changed counter status to organized and in-supply.
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_003.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================
======================================================================================================
Unit Test: UT_004
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
change_hex_control. following hexes changed to germany control (cid= 79):
change_hex_control. ERROR. invalid coordinate pair. x,y= 5000,45.
change_hex_control. ERROR. invalid coordinate pair. x,y= 0,-1.
[60,40],[60,41],[61,40],[61,41],[61,42],[62,42],[62,41],
change_hex_control. following hexes changed to japanese control (cid= 49):
[81,140],[84,140],[89,141],
change_hex_control. ERROR. invalid country input
following hc line not processed. Note. hc[0]=invalid country input.
bad_country_input,0,0,0,0,
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_004.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================
Below is the log file from the last executing of the unit test controller. I will in the following posts cover in more detail each of these unit tests.
UT.log
======================================================================================================
Unit Test: UT_001
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_001.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================
======================================================================================================
Unit Test: UT_002
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
Changed verison from 3.1.0.7 to 3.1.0.5
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_002.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================
======================================================================================================
Unit Test: UT_003
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Ita,Inf HQ,1934,0,Badoglio,0,60,
successfully moved counter from x,y= 60,42 to x,y= 61,52.
changed counter status to flipped and out-of-supply.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Italian,light aa,1939,0,20mm,0,60,
successfully moved counter from x,y= 60,42 to x,y= 61,52.
move_counters. ERROR. Unable to move and/or change counter status.
mc[country,type,year,id key,id,status,x,y]=
Italian,small aa,1939,0,20mm,0,60,
move_counters. ERROR. Unable to move and/or change counter status.
mc[country,type,year,id key,id,status,x,y]=
German,light aa,1939,0,20mm,0,60,
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
German,MIL,1936,0,LEIPZIG,99,56,
successfully moved counter from x,y= 56,27 to x,y= 61,52.
changed counter status to flipped and in-supply.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
UK,CVL,1913,0,eagle,99,46,
successfully moved counter from x,y= 46,26 to x,y= 38,22.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
NED,Convoy,1936,2,1,99,102,
successfully moved counter from x,y= 102,0 to x,y= 44,30.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Commonwealth,Oil,1936,2,2,99,47,
successfully moved counter from x,y= 47,26 to x,y= 42,26.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
German,u-boat,1939,1,4838,10,39,
successfully moved counter from x,y= 39,22 to x,y= 45,34.
changed counter status to organized and in-supply.
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_003.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================
======================================================================================================
Unit Test: UT_004
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
change_hex_control. following hexes changed to germany control (cid= 79):
change_hex_control. ERROR. invalid coordinate pair. x,y= 5000,45.
change_hex_control. ERROR. invalid coordinate pair. x,y= 0,-1.
[60,40],[60,41],[61,40],[61,41],[61,42],[62,42],[62,41],
change_hex_control. following hexes changed to japanese control (cid= 49):
[81,140],[84,140],[89,141],
change_hex_control. ERROR. invalid country input
following hc line not processed. Note. hc[0]=invalid country input.
bad_country_input,0,0,0,0,
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_004.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
Were you expecting the two ERRORs in your log file? Or should those have worked?
I thought I knew how to play this game....
RE: Utilities, Controllers & Bots, Oh My!
I'll cover that in more detail, but they were intentional. I like to also test my error handling logic. Well at least the errors that I'm trying to handle. [:D]ORIGINAL: Courtenay
Were you expecting the two ERRORs in your log file? Or should those have worked?
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
The game file that I'm starting with, "UT.GAM", is a copy of my solo game that I'm currently playing. This will serve as my "original" game file and against which I will compare the computer generated edited files.
Note that I'm currently running the public beta MWiF version 3.1.0.7

Note that I'm currently running the public beta MWiF version 3.1.0.7

- Attachments
-
- Slide5.jpg (186.25 KiB) Viewed 1718 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
All this functionality is worthless unless the edited file produced is compatible with the MWiF game engine. So the first unit test that I ran was to confirm that I could read-in (UT.GAM) and save (UT_001.GAM) a game file.


- Attachments
-
- Slide6.jpg (212.29 KiB) Viewed 1718 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
My second unit test was to confirm that I could change game file versions. This is important if one wants to revert to an earlier version of MWiF due to a the introduction of a bug in the MWiF game engine or to stay compatible with a player using an earlier version of MWiF.


- Attachments
-
- Slide7.jpg (212.92 KiB) Viewed 1718 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
Unit Test 3. Move & Change Status of Units (1/2).


- Attachments
-
- Slide8.jpg (249.54 KiB) Viewed 1718 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
Unit Test 3. Move & Change Status of Units (2/2).
======================================================================================================
Unit Test: UT_003
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Ita,Inf HQ,1934,0,Badoglio,0,60,
successfully moved counter from x,y= 60,42 to x,y= 61,52.
changed counter status to flipped and out-of-supply.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Italian,light aa,1939,0,20mm,0,60,
successfully moved counter from x,y= 60,42 to x,y= 61,52.
move_counters. ERROR. Unable to move and/or change counter status.
mc[country,type,year,id key,id,status,x,y]=
Italian,small aa,1939,0,20mm,0,60,
move_counters. ERROR. Unable to move and/or change counter status.
mc[country,type,year,id key,id,status,x,y]=
German,light aa,1939,0,20mm,0,60,
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
German,MIL,1936,0,LEIPZIG,99,56,
successfully moved counter from x,y= 56,27 to x,y= 61,52.
changed counter status to flipped and in-supply.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
UK,CVL,1913,0,eagle,99,46,
successfully moved counter from x,y= 46,26 to x,y= 38,22.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
NED,Convoy,1936,2,1,99,102,
successfully moved counter from x,y= 102,0 to x,y= 44,30.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Commonwealth,Oil,1936,2,2,99,47,
successfully moved counter from x,y= 47,26 to x,y= 42,26.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
German,u-boat,1939,1,4838,10,39,
successfully moved counter from x,y= 39,22 to x,y= 45,34.
changed counter status to organized and in-supply.
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_003.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================

======================================================================================================
Unit Test: UT_003
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Ita,Inf HQ,1934,0,Badoglio,0,60,
successfully moved counter from x,y= 60,42 to x,y= 61,52.
changed counter status to flipped and out-of-supply.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Italian,light aa,1939,0,20mm,0,60,
successfully moved counter from x,y= 60,42 to x,y= 61,52.
move_counters. ERROR. Unable to move and/or change counter status.
mc[country,type,year,id key,id,status,x,y]=
Italian,small aa,1939,0,20mm,0,60,
move_counters. ERROR. Unable to move and/or change counter status.
mc[country,type,year,id key,id,status,x,y]=
German,light aa,1939,0,20mm,0,60,
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
German,MIL,1936,0,LEIPZIG,99,56,
successfully moved counter from x,y= 56,27 to x,y= 61,52.
changed counter status to flipped and in-supply.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
UK,CVL,1913,0,eagle,99,46,
successfully moved counter from x,y= 46,26 to x,y= 38,22.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
NED,Convoy,1936,2,1,99,102,
successfully moved counter from x,y= 102,0 to x,y= 44,30.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
Commonwealth,Oil,1936,2,2,99,47,
successfully moved counter from x,y= 47,26 to x,y= 42,26.
move_counters. Success. Found unit.
mc[country,type,year,id key,id,status,x,y]=
German,u-boat,1939,1,4838,10,39,
successfully moved counter from x,y= 39,22 to x,y= 45,34.
changed counter status to organized and in-supply.
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_003.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================

- Attachments
-
- Slide9.jpg (326.68 KiB) Viewed 1718 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
Unit Test 4. Change Hex Control (1/2).


- Attachments
-
- Slide10.jpg (156.79 KiB) Viewed 1718 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
Unit Test 4. Change Hex Control (2/2).
======================================================================================================
Unit Test: UT_004
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
change_hex_control. following hexes changed to germany control (cid= 79):
change_hex_control. ERROR. invalid coordinate pair. x,y= 5000,45.
change_hex_control. ERROR. invalid coordinate pair. x,y= 0,-1.
[60,40],[60,41],[61,40],[61,41],[61,42],[62,42],[62,41],
change_hex_control. following hexes changed to japanese control (cid= 49):
[81,140],[84,140],[89,141],
change_hex_control. ERROR. invalid country input
following hc line not processed. Note. hc[0]=invalid country input.
bad_country_input,0,0,0,0,
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_004.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================

======================================================================================================
Unit Test: UT_004
date and time (start): 07/22/2020, 19:55:28
Read in game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT.GAM
change_hex_control. following hexes changed to germany control (cid= 79):
change_hex_control. ERROR. invalid coordinate pair. x,y= 5000,45.
change_hex_control. ERROR. invalid coordinate pair. x,y= 0,-1.
[60,40],[60,41],[61,40],[61,41],[61,42],[62,42],[62,41],
change_hex_control. following hexes changed to japanese control (cid= 49):
[81,140],[84,140],[89,141],
change_hex_control. ERROR. invalid country input
following hc line not processed. Note. hc[0]=invalid country input.
bad_country_input,0,0,0,0,
Wrote out game file: C:\Users\rkrun_000\Documents\Python\MWIF\game_files\UT_004.GAM
date and time (finished): 07/22/2020, 19:55:28
======================================================================================================

- Attachments
-
- Slide11.jpg (320.39 KiB) Viewed 1718 times
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
Alright, I think that's enough pulling together charts on this for now. It's time to do some more coding, but more importantly to do some more playing. After all, that is what all of this is about. Playing the game and having fun. [:)]
Ronnie
RE: Utilities, Controllers & Bots, Oh My!
Me likey. Good job man 

RE: Utilities, Controllers & Bots, Oh My!
Thanks! [:)]ORIGINAL: markb50k
Me likey. Good job man![]()
Ronnie