PyCMO is a reinforcement learning environment for Command Modern Operations written in Python. It exposes the game as slices of observation, reward, and available actions that get returned at each timestep.
This project was submitted to the NSIN AI for Command Challenge 2021.
- Python 3.9.2
- pip
- Make sure the following settings are enabled in your Command Modern Operations' configurations (in
CPE.ini
):
[Lua]
EnableSocket = 1
SocketPort = 7777
AllowIO = 1
EncodingMode = 8
- Click on "Clone or download", and then "Download Zip".
- Unzip the repo anywhere.
- Configure the project's
pycmo/configs/config.py
file to fit your system's paths. Do not change the amount of backslashes that are present in each entry as that could mess up its usage! If thesteps
directory is not present inraw
then create it.
{
"command_path": "C:\\Program Files (x86)\\Command Professional Edition 2\\",
"observation_path": "C:\\\\Users\\\\AFSOC A8XW ORSA\\\\Documents\\\\Python Proj\\\\AI\\\\pycmo\\\\raw\\\\steps\\\\",
"scen_ended": "C:\\\\Users\\\\AFSOC A8XW ORSA\\\\Documents\\\\Python Proj\\\\AI\\\\pycmo\\\\pycmo\\\\configs\\\\scen_has_ended.txt",
"command_cli_output_path": "C:\\ProgramData\\Command Professional Edition 2\\Analysis_Int"
}
- Navigate to the folder than contains
setup.py
and install the repository usingpip install .
Anytime you make changes to the files in the project folder, you need to reinstall the package usingpip install .
.
1a. Open a terminal within the game's directory and load a scenario in Interactive mode. For example,
./CommandCLI.exe -mode I -scenfile "C:\ProgramData\Command Professional Edition 2\Scenarios\Standalone Scenarios\Wooden Leg, 1985.scen" -outputfolder "C:\ProgramData\Command Professional Edition 2\Analysis_Int"
1b. Alternatively, open a terminal anywhere and call pycmo/lib/start_server.py
to start a scenario in Interactive mode. The path to the scenario must be supplied, e.g.
python pycmo/lib/start_server.py "C:\ProgramData\Command Professional Edition 2\Scenarios\Standalone Scenarios\Wooden Leg, 1985.scen"
- Call
python pycmo/bin/agent.py
to run the main loop with the following arguments.
-agent AGENT Select an agent. 0 for RandomAgent, 1 for ScriptedAgent, 2 for RuleBasedAgent.
-size SIZE Size of a timestep, must be in "hh:mm:ss" format.
-scenario SCENARIO The name of the scenario, used for ScriptedAgent and RuleBasedAgent. Usually the literal name of the .scen file.
-player PLAYER The name of player's side.
The default is to run a RandomAgent on Wooden Leg with a timestep of 1 minute. Accepted scenario file names for the -scenario
parameter above are
scenario_id = {
'Operation Brass Drum, 2017',
'2 - English Jets over Uganda, 1973',
'Fighter Weapons School - GAT 5 and 6, 1977',
'Iron Hand, 2014',
'Khark Island Raid, 1985',
'North Pacific Shootout, 1989',
'Pyrpolitis 1-14, 2014',
'Sea of Fire, 1982',
'Shamal, 1991',
'Task Force Normandy, 1991',
'Wooden Leg, 1985',
'None'
}
For a full description of the specifics of how the environment is configured, the observations and action spaces work read the environment documentation.