Thanks, interesting stuff! This is an area where I have relatively little to contribute unfortunately. But now that we basically have / are very close to having the code in Python, but with limitations in performance (see Liral's post - hence hunting for optimizations), do you have ideas about how to improve the strategy for testing, say, ship variants against each other, or a very large number of weapons versus a set of ships in order to rank them by some attribute?
I have ideas about ways of running numerical optimization on loadouts using some sort of combat model, but I think we are still quite far from having a simulation that is actually useful for that purpose.
In terms of performance, I think the issues are a little overstated. On my laptop (2019 Intel MacBook Pro, 2.3 GHz I9), my MATLAB code (which is not super optimized) takes about ~7 seconds to run the armor damage calculations 1000000 times (without any parallelization). My laptop has relatively unimpressive clock speed and 8 cores, so I would expect 3-6x reduction in time with parallelization based on personal experience. I would expect comparable performance (or better with good optimization) in python.
Based on my experience, most combat simulations take a few hundred shots for a kill, so that 1000000 armor damage calculations probably corresponds to 1-2 thousand combat simulations. I think that speed should be sufficient to run optimization code in a reasonable amount of time (several minutes). Obviously any improvements would be great though. Brute force searching all possible combinations of weapons/loadouts for a ship is still probably out of the question though just due to the combinatorics of how many possible ways there are to create a loadout. Obviously this is all very ‘back of the napkin’ approximations.
Here is my assessment of where we are and what we still need to do:
Current state (feel free to add anything I am missing):
in python:
- armor damage calculations (given hit strength and armor grid)
- expected armor damage (given shot distribution, hit strength and armor grid)
- some shot distribution calculations (given range, armor grid dimensions)
in R:
- more complex weapon mechanics (beams, charge up/charge down, burst weapons)
- some rudimentary AI for shield management
- a basic simulation
The remaining non-translated R code is mostly part of the broader simulation rather than the damage calculations. We still need to build out all the simulation code in python that calls the damage calculations.
In order to do numerical optimization, what we need is a function which takes all of the parameters to be optimized (loadout, hopefully including all weapons, hullmods, caps/vents), as well as the simulation parameters (ships, skills, opponent loadout etc.) and runs the simulation to return the value of the metric that we are trying to improve for that specific case. We will also likely need to write some constraint functions, but we can worry about that later.
What I think we need to do:
- translate remaining R code for weapon mechanics and stuff to python
- this might require to some reformulation depending on how the simulation is implemented in python
- create a simulation structure in python
- need to handle flux dynamics, including soft/hard flux from both firing weapons and shield damage
- need to figure out time steps to handle all the different types of weapons (beams, burst weapons etc.)
- IMO we need to handle variable range as well (will talk about this later)
- create a programatic system for getting appropriate weapons and ship data
- I know Liral was trying to do this for weapons stats from the CSV file already
- ship stats should be similar (parsing a CSV file), unless we try to handle actual ship geometry for the armor grid, and need to pull that data (which is not in a file format I am familiar with)
- choose a metric to optimize and create a function that utilizes the simulation to calculate that metric
- wrap this in the optimization code (probably from a generic optimization package, I can handle this)
Handling range is something I’ve been think about. Obviously, the big issue is that the shot distribution depends on range, and we don’t want to be recalculating that constantly, but I have some ideas when we get there. We would also need some rudimentary AI to manage range for each ship.
Also, I think we are definitely getting to the point where a GitHub would be very helpful for collaboration. I think the method of copy/pasting code from the forum will get very inefficient very fast. I am happy to write some code.