Battle simulation

Describe your experience with the latest version of FreeOrion to help us improve it.

Moderator: Oberlus

Forum rules
Always mention the exact version of FreeOrion you are testing.

When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Message
Author
User avatar
Oberlus
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Battle simulation

#16 Post by Oberlus »

Simulation is OK IMO. I was answering to Ophiuchus suggestion of not providing statistical results.

truepurple
Space Kraken
Posts: 156
Joined: Tue Jul 06, 2021 12:09 am

Re: Battle simulation no one looks here... *runs around naked*

#17 Post by truepurple »

Oberlus wrote: Fri Jul 09, 2021 7:38 pm Simulation is OK IMO. I was answering to Ophiuchus suggestion of not providing statistical results.
Oberlus wrote: Fri Jul 09, 2021 7:31 pm If the simulation makes many simulations to provide statistical results, it will take some time, but not much if it's just 10 or 20 combats.
If the simulation does a single random combat, players will use it several times and take notes until they are confident on the result, and that will take more time and be annoying for other players waiting for next turn (it has happened before with players that were running their own simulations). I really dislike that.
So if this is done, I prefer giving statistical results (e.g. worst, best, average in terms of allied ships lost vs enemy ships lost).
UI isn't obvious, specially if there are several fleets (which will happen often in multiplayer with alliances). How to select the fleets that will participate in the battle when they are not yet in a single system?

Again, the game doesn't necessarily need to run actual battles to give some statistics. AFAIK BfW just computes the known variables and lists the odds, it doesn't even bother running phantom battles. That is why the odds BfW gives in any particular scenario will always be identical. Granted FO might have more complicated math, but does that mean you can't use the same method? Thus much less computation and time will be necessary.

That is why I said maybe I shouldn't have used the word "simulation" but lacked an alternative I could think of.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Battle simulation no one looks here... *runs around naked*

#18 Post by Geoff the Medio »

truepurple wrote: Fri Jul 09, 2021 9:13 pmAFAIK BfW just computes the known variables and lists the odds, it doesn't even bother running phantom battles. That is why the odds BfW gives in any particular scenario will always be identical. Granted FO might have more complicated math, but does that mean you can't use the same method?
Wesnoth provides statistical distributions for single-turn attacks by one unit on another for a particular defender terrain type. This is, as far as I know / recall, a binomial distribution based on number of strikes and chance to hit. This is a simple enough calculation that there is really no distinction between a "simulation" and "just comput[ing] the known variables and list[ing] the odds".

A battle simulation for FreeOrion would be, on a pseudo-logarithmic scale of complexity, half way between that and simulating the whole combat scenario in Wesnoth, which would involve the units moving around, players doing recruitment and recalls, and multiple attacks over multiple turns by various combinations of units against eachother.

Similarly, rather than a single ship attacking another single ship once, a combat simulation for FreeOrion would involve setting up a combat scenario with multiple ships that attack multiple targets per combat round, can be destroyed mid-combat, launch and destroy fighters, and have stealth removed after attacking.

That's not as complex as the full combat Wesnoth case, which involves recruitment and recalls, since the combat forces in a FreeOrion battle don't substantially change during a battle (aside from destruction of ships or the automatic launching of fighters, which critically don't involve any player input), but there is no way to "just compute" the odds of that, either.

truepurple
Space Kraken
Posts: 156
Joined: Tue Jul 06, 2021 12:09 am

Re: Battle simulation

#19 Post by truepurple »

I see.

Though if the game just gave you the statistics for each ship match up and not tried to give odds of victory of a battle as a whole, I'd be happy with that too. If it were just ship to ship match ups, the would it be possible to avoid full battle simulation running?

Which ship configurations are more effective would be very edifying in of itself, perhaps even more so long term than what battle results might happen. I could even then experiment with different ship configurations and use this to immediately know which is best against X foe by testing with a mixed fleet.

defaultuser
Juggernaut
Posts: 854
Joined: Wed Aug 26, 2015 6:15 pm

Re: Battle simulation

#20 Post by defaultuser »

LienRag wrote: Fri Jul 09, 2021 6:52 pm
defaultuser wrote: Thu Jul 08, 2021 11:31 pm I you do decide to add something, I think it should be a research item and have levels.
Very bad idea imho.
Pre-battle calculations are for the player, not the Emperor, so it should never have an in-game price.
You don't think a fleet commander or strategist back at HQ would be interested in battle simulation results? I think I'd have to disagree. I'll also point out that a number of times when I mentioned things not making sense in the game universe I was chastised for thinking that had much importance.

User avatar
LienRag
Cosmic Dragon
Posts: 2146
Joined: Fri May 17, 2019 5:03 pm

Re: Battle simulation

#21 Post by LienRag »

defaultuser wrote: Mon Jul 12, 2021 11:43 pm You don't think a fleet commander or strategist back at HQ would be interested in battle simulation results?
Non-sequitur.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Battle simulation

#22 Post by Geoff the Medio »

truepurple wrote: Sat Jul 10, 2021 1:34 pmIf it were just ship to ship match ups, the would it be possible to avoid full battle simulation running?
It would still be more complicated than a Wesnoth attack, as there are potentially many weapons attacking each combat round and multiple shots per attack, in addition to fighter launches and destruction, and stealth reveals after attacks. Implementing it would probably be more like simulating a 1 on 1 battle than a Wesnoth attack calculation.

It also wouldn't be very meaningful for many cases, since in large multi-ship combats, ships don't focus their attacks on a single target ship, but in most 1 on 1 battles, they would.

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Battle simulation

#23 Post by Ophiuchus »

Geoff the Medio wrote: Tue Jul 13, 2021 9:30 am
truepurple wrote: Sat Jul 10, 2021 1:34 pmIf it were just ship to ship match ups, the would it be possible to avoid full battle simulation running?
...
It also wouldn't be very meaningful for many cases, since in large multi-ship combats, ships don't focus their attacks on a single target ship, but in most 1 on 1 battles, they would.
The combat system uses a complete randomness each battle bout, and each bout depends on the previous one. Its hard to compress that.

For a large speedup we probably would need to get rid of per-bout calculation.
This could be easily done iff we ignore dead ship results (which of course would give really stupid results). Anyway it would still need a heuristic for the death-of-fighters.
Also the heuristics probably would need to be redone every time combat system changes.

For a human player i do not think that there is really a benefit of not doing a "real battle". Battles processing should be fast/cheap. (and it should be done either on client side in order to not expose server knowledge or make it a server API as a function, so not using any server state).

Anyway I dont see why one should not use real battles to "simulate" battles for human players. For AI it might be nice to have some less processing intense options for doing many decisions. But lets start talking about that if we find out that AI uses too much CPU by calculating battle results. And the first approach to fixing would be probably to optimize battle speed to bring down turning for everyone.

What I wanted to say: the number of fighters, of shots, of damage per shot, of structure, of shields are the atoms of any combat (plus targeting). If you have a single ship, these are also "true" (without information loss).
If you have some experience with the game you will know what that will mean.
If you have a fleet and an idea about the different design/the composition of the fleet, sums of fighters/shots/structure, number of ships (or average of structure), average shields are quite meaningful. I just did some improvements to the UI in master for that purpose as the "recent" changes that some weapons only target some kind of enemies made the numbers a lot less meaningful. So the damage to ships and damage to fighters is counted separately in the UI.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Oberlus
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Battle simulation

#24 Post by Oberlus »

Yes, an approximation is possible. That is what I already do (mental calculations):
# Enemy shots * (Enemy average damage per shot / average allied shield) = shot damage taken.
Enemy average anti-ship fighter shot damage * (# Enemy anti-ship fighters / # allied anti-fighter shots) = fighter damage taken.
The sum of the both above over total allied structure = average total damage taken per ship.
The last calculation is the less accurate of the three, specially if allied forces have heterogeneous structure per ship or shields.

User avatar
LienRag
Cosmic Dragon
Posts: 2146
Joined: Fri May 17, 2019 5:03 pm

Re: Battle simulation

#25 Post by LienRag »

Ophiuchus wrote: Tue Jul 13, 2021 11:26 am
The combat system uses a complete randomness each battle bout, and each bout depends on the previous one. Its hard to compress that.
Would a monte-carlo simulation be hard to implement/too costly for the client¹ ?
Then you give worse, average and best results...



¹ If made optional with a warning on low configurations, the CPU cost for the client would not be that much of a problem anyway.

User avatar
Oberlus
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Battle simulation

#26 Post by Oberlus »

No need of Monte Carlo. Just run a few combats (20?) and get some statistics from the results.

truepurple
Space Kraken
Posts: 156
Joined: Tue Jul 06, 2021 12:09 am

Re: Battle simulation

#27 Post by truepurple »

How much randomness is in the game? And do we really need this much randomness? If we cut down on the randomness, would that help calculate simulation results? I think it might because the more randomness, the more times the simulation needs to be run to get a reasonably reliable average of the odds.

User avatar
Oberlus
Cosmic Dragon
Posts: 5714
Joined: Mon Apr 10, 2017 4:25 pm

Re: Battle simulation

#28 Post by Oberlus »

Randomness is necessary for fun.

truepurple
Space Kraken
Posts: 156
Joined: Tue Jul 06, 2021 12:09 am

Re: Battle simulation

#29 Post by truepurple »

Oberlus wrote: Tue Jul 13, 2021 9:06 pm Randomness is necessary for fun.
In your opinion, your opinions aren't "facts".

There are games that remove much randomness and are still fun. Also there are degrees of randomness. A weapon might do between 8-12 damage, or it might do between 1-20 damage, both are random, but the latter will need much more simulation runs for a true representation of odds.

Are you suggesting we need maximum randomness so players can't count on anything and winning is as much about a RNG result as anything else?
Last edited by truepurple on Tue Jul 13, 2021 10:09 pm, edited 2 times in total.

User avatar
LienRag
Cosmic Dragon
Posts: 2146
Joined: Fri May 17, 2019 5:03 pm

Re: Battle simulation

#30 Post by LienRag »

Oberlus wrote: Tue Jul 13, 2021 9:06 pm Randomness is necessary for fun.
No it isn't.
The way the combat system works in FO, I believe also that the randomness is more interesting that removing it.
But deterministic systems could be fun too, and truepurple is right that there are "levels" of randomness.

Not that his suggestion to basically remove all parts of the game that he doesn't understand has any merit, but game design should be done on an objective basis, not on epidermic reactions to someone annoying.

Post Reply