OpenXcom Forum

Contributions => Programming => Topic started by: OmniscientQ on May 31, 2020, 05:06:23 am

Title: Auto-Battle
Post by: OmniscientQ on May 31, 2020, 05:06:23 am
X-COM Auto-Battle

One of the few features of the old xcomutil by Scott Jones yet to be implemented in OpenXcom is the auto-battle feature. For those who don’t remember, it was an option that would allow the player to automate tactical combat.

It didn’t hand control of your troops off to the AI to finish the battle. Instead, it reduced the participants on both sides to a couple of abstracted numbers, and then rolled some dice. If I’m recalling correctly, it made some sweeping assumptions. Ammunition wasn’t actually consumed. Fire rates didn’t matter. You had a basic 5% chance to capture rather than kill. Night missions applied a huge penalty that was partially offset for any soldier carrying a flare. Psionics basically amounted to an “I win” button. The xcomutil feature could also be invoked mid-battle. Once you had cleared the bulk of the alien forces, tipped the score in your favor, you could leave the clean-up to the grunts.

Some people might be tempted to say that an auto-battle function is cheating, or it defeats the whole point of the game, but I have a few reasons for thinking that OpenXcom would benefit from having one. In no particular order:

1 – One of the self-imposed challenges proposed in the xcomutil readme, and one I enjoyed, was to run auto-battle on every mission, and never assume direct control (Insert Mass Effect meme here). Being unsure of whether you’ll get the live Navigator or Deep One in your first month means having to change things up, and poses some new challenges.

2 – Sometimes, you just can’t stomach the thought of going through the motions to retrieve a medium scout full of Floaters, or to track down the last alien who's hiding in a closet. Even when you don’t have the flying power armor and psionic amplifiers to make such a mission risk-free, it’s just a chore to go after another wreck. Then there are the wonderful mods that border on being total-conversions, like X-Piratez and X-COM Files, where a single campaign *will* last for several years. Two years into a Piratez game, I feel guilty about letting Warehouse Wars missions despawn, but they feel like a chore just like the hypothetical medium scout full of floaters.

3 – The Android port of OpenXcom is wonderfully done, but a touchscreen is sometimes a pain in the ass. For some reason, it feels forgivable to me when I’m doing anything on the strategic level, but the tactical side leaves me frustrated at the lack of a mouse. If I could automate combat while on my tablet, I would.

If an auto-battle feature were to be created for OpenXcom, how would you want it to work? Would you want something fairly vague like the xcomutil version, or would you want the game to track every single movement and shot? A more abstract system might make it easier to work with mods in the mix, though the results might not reflect how difficult the mission would have been if it were played out manually. Would you want a status screen that shows the relative strengths of each side as the battle progresses, perhaps with simple buttons to influence it (something along the lines of Cautious, Standard, Aggressive, Retreat), or should it jump straight to the battle summary? Should it be made interruptible, so that the player can step back in if something goes horribly wrong (Much harder to implement. Where do you place all the units?)

I realize this falls outside the scope of OpenXcom, or even OXCE. The OXC mission statement was to faithfully recreate X-COM without the bugs and limitations imposed by hardware of the time. Adding an auto-battle feature means designing an entirely new system for which there's no canonical reference, so I want to get some input and feedback, and maybe even some semblance of consensus on what it should look like.
Title: Re: Auto-Battle
Post by: vadracas on May 31, 2020, 08:12:20 pm
If an auto-battle feature were to be created for OpenXcom, how would you want it to work? Would you want something fairly vague like the xcomutil version, or would you want the game to track every single movement and shot? A more abstract system might make it easier to work with mods in the mix, though the results might not reflect how difficult the mission would have been if it were played out manually. Would you want a status screen that shows the relative strengths of each side as the battle progresses, perhaps with simple buttons to influence it (something along the lines of Cautious, Standard, Aggressive, Retreat), or should it jump straight to the battle summary? Should it be made interruptible, so that the player can step back in if something goes horribly wrong (Much harder to implement. Where do you place all the units?)



Actually, if the same AI that the enemies use could just be substituted in as the player, the difficulty of implementation would be similar(but in a different area) to balancing out an abstract points system.
Title: Re: Auto-Battle
Post by: OmniscientQ on May 31, 2020, 11:24:45 pm

Actually, if the same AI that the enemies use could just be substituted in as the player, the difficulty of implementation would be similar(but in a different area) to balancing out an abstract points system.

One of my biggest concerns was how to get an auto-battle feature to incorporate mods, and do justice to the intended balance of the mods. That's one of the best arguments I can find in favor of turning the X-COM units over to the same AI that runs the aliens, and just let it play out. Then the auto-battle would be running by exactly the same rules that the mod author already balanced towards. The AI would be dumb as hell, but that'd just be the trade-off the player accepts by using it. Would you want to be able to watch the battle play out? It'd be useful, if the player were allowed to interrupt and take control back. On the other hand, if you just want the battle to be done, being forced to watch half a dozen turns of "Hidden Movement" flash across your screen could get annoying fast. I do think I'd personally prefer that the game get to the battle summary as fast as possible once I hit the button.

I think I recall a post by Meridian stating that turning X-COM units over to the AI wasn't possible, but a quick forum search didn't find it. It may be the case that this isn't possible.
Title: Re: Auto-Battle
Post by: vadracas on June 01, 2020, 01:10:41 am
Currently, you can't turn them over to the AI, all of these suggestions require changes to source code. By the way, no matter what you would see the long-hidden movement times if you turn the player over to the AI do to most of that being the AI figuring out LOS and what to do. The ability to interrupt would probably be pretty doable by using the right-click functionality that can already interrupt movement, but that's all that you would be able to interrupt.

The abstraction is a completely different matter.



By the way, I am certainly not asking ANYONE to do this unless they are very interested as this would be a challenging task.
Title: Re: Auto-Battle
Post by: NancyGold on July 06, 2020, 08:01:00 pm
It didn’t hand control of your troops off to the AI to finish the battle. Instead, it reduced the participants on both sides to a couple of abstracted numbers, and then rolled some dice.
Given that aliens always have numerical and firepower superiority, that wont ever work in a fair playground. So yeah, it has to make assumptions. Moreover, players always has a chance to retreat, taking away some stuff. For me it was always Chryssalid present = instant retreat.

Some people might be tempted to say that an auto-battle function is cheating, or it defeats the whole point of the game, but I have a few reasons for thinking that OpenXcom would benefit from having one. In no particular order:
Yeah. It makes a totally different game, similar to Civilization, or more precisely to Emperor of the Fading Suns, which had stack autocombat, with different type units getting different initiative (i.e. artilery goes before tanks).

The whole point of XCOM is tactical combat, while the strategic world map is here just to glue the tactical missions into a coherent story.

In my XCOM inspired game I do have autocombat, but it is used only for AI vs AI battles, since properly simulating battle scape would take some time and annoy human players.
Title: Re: Auto-Battle
Post by: humbe on August 14, 2020, 02:37:34 pm
It would be very nice to have. If someone feels it is cheating, then just don't use it. Someone might just want to test out playing just the strategic bits. Maybe testing out the game, learning what techs exist, or just because they prefer to, so why not? And some might find some missions tedious and want to finish a mission they've started or just want to automatically handle a mission that is easy at that point.

But it's not easy to implement (so I don't expect such a feature to come). In games that has an AI, in a player vs AI battle on equal terms, it is easy to use the AI engine to play for the player too.. But aliens and X-Com soldiers don't fight on equal terms, so leaving it up to the AI may require quite a bit of code, and would probably not work that well.. The game is kind of forgiving for a poor AI, as you don't want to lose half the battles because the AI is too smart and has a tactical advantage from the start.

Just evaluating some dice and rolling some dice sounds like a horrific implementation in my mind. A proper AI implementation that played like a not too overly dumb human would be preferrably, but probably too much work.

Something doable would be to automate camping strategies. But likely too situational for someone to bother implementing.. For instance it could work something like this:

 - Enable recording of camping auto-play.
 - Move the players you want to move.
 - Press auto-play, this will end your turn and start auto-mode, which may (possibly optionally?) hide what happens while in auto-mode to be able to speed it up.

- In alien turns your forces will of course just do reaction shots.
- In your own turn, if any of your soldiers see an alien, shoot at him, preferring to use soldiers the alien cannot see first (as in, use soldiers with line of sight that cannot spot the alien themselves)
- The soldiers you moved when recording, will try to do the same movement pattern each turn ending back up in the same spot (including facing). If they spot an alien, shoot at it, again preferring to use soldiers the alien doesn't see first.
- If the aliens kill any of your soldiers, or give them fatal damage, abort and let you take back control.
Title: Re: Auto-Battle
Post by: Meridian on August 14, 2020, 02:51:47 pm
It would be very nice to have. If someone feels it is cheating, then just don't use it. Someone might just want to test out playing just the strategic bits. Maybe testing out the game, learning what techs exist, or just because they prefer to, so why not? And some might find some missions tedious and want to finish a mission they've started or just want to automatically handle a mission that is easy at that point.

If you want to cheat or to test strategic functionality, there are already cheats available to either kill or stun all enemies. Same applies if you feel a mission is tedious.
Title: Re: Auto-Battle
Post by: Bonakva on January 09, 2021, 07:09:58 pm
If you want to cheat or to test strategic functionality, there are already cheats available to either kill or stun all enemies. Same applies if you feel a mission is tedious.
These cheats are sterile. They do not allow pumping soldiers. In the mid / late game, missions to exterminate spiders, zombies, etc. cause laughter. My soldiers are 100% victorious in such battles. This is 100% pumping and getting medals. But this is a very long time and you have to cheat. The auto battle theme has been relevant for a very long time. Many people ask. Many people want it. It is foolish to answer every time that you need to use cheats.
Title: Re: Auto-Battle
Post by: Meridian on January 09, 2021, 07:43:50 pm
These cheats are sterile. They do not allow pumping soldiers. In the mid / late game, missions to exterminate spiders, zombies, etc. cause laughter. My soldiers are 100% victorious in such battles. This is 100% pumping and getting medals. But this is a very long time and you have to cheat. The auto battle theme has been relevant for a very long time. Many people ask. Many people want it. It is foolish to answer every time that you need to use cheats.

I believe any such feature would be detrimental to the normal xcom gameplay.
And I won't implement features that I don't believe in.

If you're playing mods that send your supersoldiers to kill helpless cows, you are free to switch to different mods, that don't do that and give you a balanced challenge.

With all due respect, I don't see many people asking for it.
A dozen or so is not many. It's a few.

Lastly, OpenXcom is and will always be free and open.
Feel free to implement any feature you like and share it with others if you want... even in this very thread.
Title: Re: Auto-Battle
Post by: Bonakva on January 11, 2021, 01:42:22 pm
I believe any such feature would be detrimental to the normal xcom gameplay.
And I won't implement features that I don't believe in.

If you're playing mods that send your supersoldiers to kill helpless cows, you are free to switch to different mods, that don't do that and give you a balanced challenge.

With all due respect, I don't see many people asking for it.
A dozen or so is not many. It's a few.

Lastly, OpenXcom is and will always be free and open.
Feel free to implement any feature you like and share it with others if you want... even in this very thread.

Topics related to auto combat or similar mechanics have been floating around since 2011.
Many people do not write about this simply because they do not want to register, create a topic, and the like. I am one of those who registered on the forum only after five years of playing.
I think a lot of people would like this feature if it were the default. I am sure that such a function would make life easier for more than a dozen people.
It must be understood that depending on the mod, the duration of the game and the types of missions are greatly increased. If, conventionally, for vanilla such a function is not necessary, then for mods that take 5 times longer, such a setting is already relevant.

I understand your position. Anything that damages the gameplay in the trash.
If I could implement something like this I would do it and put it out for everyone. Unfortunately my knowledge of coding is not enough to create something like this. I just have to wait for a person who can realize it.

By the way, as far as I know, cheats work only when the debug mode is activated. Not every person will think of activating it. Not everyone will seek a solution to a problem.
What I mean is that the vast majority of people use only what is given by default. Many do not even know that files can be edited with notepad...
Title: Re: Auto-Battle
Post by: Yankes on January 11, 2021, 07:20:17 pm
Quote
If I could implement something like this I would do it and put it out for everyone.
More import HOW. And not in sense of OXC code base but algorithm that should give you result.
What you will consider and what you will ignore? Consider that weapon hit can have arbitrarily result in OXCE, how you model it?
Do you consider possible maps that have checkpoints that have great impact on final results?
Or Chryssalid, how you model something like that? Even one have potential easy kill every one of xcom team.

Only think way to implement somting close to this is simply auto surrender for aliens if you are overpowered, and this already is partially implemented by Meridian.
Title: Re: Auto-Battle
Post by: Meridian on January 11, 2021, 09:37:15 pm
Let's be honest... nobody would ever accept any auto-result, if they lost even a single soldier.

Everyone will ask for a feature that if auto-result loses even one soldier, they should get a chance to replay the whole battle manually.
(or even worse, they will bad-mouth me, that I am not capable of creating even a "simple" auto-result algorithm and that I have to "fix it" or else they come and kill my dog)

And we're back to an auto-win cheat button... no, thank you.
Title: Re: Auto-Battle
Post by: WaldoTheRanger on January 11, 2021, 10:27:11 pm
Yankes makes a very good point about the surrender feature.

Maybe the solution to the issue as it applies to huge modpacks is for the pack makers to apply this feature more aggressively.

Like for example, if over half of the enemy is killed without them getting a single one of your soldiers, they surrender.
If they get bombarded by like, 5-10 blaster bombs in a row (proportional to how many enemies there are and the missions type) then they surrender
If over half of them are mind controlled, they surrender.

I don't know if those things are done already, but the point is they could be adjusted to reduce tedium even more.

It could also be an interesting tactical choice. Like if you're not well enough equipped to actually take on a snakeman supply ship, but you have like, 5 blasters, or 20 high ex that you can throw at the door, maybe you're able to intimidate them into giving up before they should have.
Title: Re: Auto-Battle
Post by: WaldoTheRanger on January 11, 2021, 10:33:02 pm
If it's not too hard to implement, there could also be a way to make the surrender function apply differently to different races, and at different x-com tech levels.

so for example, xcf cultists have different surrender conditions than a snakeman terror ship would, and they also change their surrender conditions once xcom has gotten promotion 3/4 or something.

That way you don't have cultist safehouses still trying to fight you once you can just blasterbomb the entire map all at once. once you're powerful enough they freak and run as soon as you leave the ship.

basically has the same result as an auto-resolve if all you're trying to do is remove the tedious mop up missions.
Title: Re: Auto-Battle
Post by: Meridian on January 11, 2021, 10:42:23 pm
basically has the same result as an auto-resolve if all you're trying to do is remove the tedious mop up missions.

Bonakva calls this sterile, because it doesn't give experience.

He doesn't want to remove the tedium, he wants to keep and automate the tedium, i.e. let the game play itself...
Title: Re: Auto-Battle
Post by: Yankes on January 11, 2021, 10:50:06 pm
Let's be honest... nobody would ever accept any auto-result, if they lost even a single soldier.

Everyone will ask for a feature that if auto-result loses even one soldier, they should get a chance to replay the whole battle manually.
(or even worse, they will bad-mouth me, that I am not capable of creating even a "simple" auto-result algorithm and that I have to "fix it" or else they come and kill my dog)

And we're back to an auto-win cheat button... no, thank you.
When I hear  auto-result I always recall some video review of (probably) TotalWar where when you auto-battle you always loose canons even they should be on back of your wining army :>
But on other hand what if "losing solder" was part of this mechanic? you sacrifice you soldier on altar of RngGod for best outcome, more hard enemy you need sacrifice soldier with more stats :D
Title: Re: Auto-Battle
Post by: WaldoTheRanger on January 11, 2021, 11:01:15 pm
Bonakva calls this sterile, because it doesn't give experience.

He doesn't want to remove the tedium, he wants to keep and automate the tedium, i.e. let the game play itself...

Well I don't care.
It would solve the issue for me, and I imagine most people.
Title: Re: Auto-Battle
Post by: Solarius Scorch on January 12, 2021, 12:35:34 pm
Watching the AI play again itself would be fun. Once.

Except it wouldn't really work, because the X-Com AI is unable to put together a simplest tactical plan. It would devolve into random movements and occasional chance shots, which in my opinion is 0% accurate in simulating a human player, even a really bad one. It wouldn't even be entertaining to watch.
Title: Re: Auto-Battle
Post by: The Reaver of Darkness on January 21, 2021, 02:40:59 pm
I think it would be nice to simply let the computer play while you watch, with the ability to shut it off at any time and reassume control. The computer would almost invariably play worse than the human player, but if your squad has the deck stacked well enough in your favor you could get it done with sufficiently low casualties. It would really help remove some of the slog of running too many missions, and may also lead to equipment strategies related to getting the AI to do a better job when playing for you. For example never put blaster bombs into the hands of the AI because as you've probably seen the aliens do, they kill themselves more often than they kill their opponents.

One thing you'd definitely not be accused of doing is cheating, as even at its best, the AI is brazenly stupid.
Title: Re: Auto-Battle
Post by: spawi on May 14, 2021, 01:51:19 am
+1 for automating tedious battles. The more the outcomes resemble actual battlescape session, the better. However, some very simplified abstract formulas would also work; at least at first. As to soldier loses in such battles: I expect some tweaking / configuration would solve this. Plus self-imposed half-ironman, i.e. only for automated battles. I really, really don't want to spend time equipping 12 of my soldiers only to arrive, search, find, shoot and kill 1 zombie that was hiding in the closet on the opposite end of the map. 1 zombie vs 12 soldiers should (almost?) never result in a soldier being lost (wounded is fine). But 12 soldiers vs 30 zombies is a different story.

There are so many cool things one could do with such a feature. E.g.:
- allow to decide if the player wants to do auto-battle upon arrival, when enemy type and count is better known.
- allow the player to order retreat, if the auto-battle is not going well. This might still incur loses, but possibly less.
- decide how careful the soldiers should be, willing to risk their life to capture a live specimen. More risky mission orders could result in bigger payoffs (more enemies captured, less destruction, less civilian deaths) but also result in possibly bigger loses, due to the ordered restraint.
- limit the amount of missions player can command manually; e.g. one per week max. The rest has to be auto-resolved.
- make the ability to auto-resolve a mission be unlocked as a reward, if the player previously won 5+ of missions of given type, or against given enemy type, or both.
- allow to auto-resolve given mission only if the player has crushing advantage, given some formula. Like at least 2 to 1.
- decide which soldiers are on the front-line (rookies, naturally) and which are hanging out in the back and thus at lesser risk.

I think this has huge potential to make the game more streamlined and enjoyable.
Title: Re: Auto-Battle
Post by: WaldoTheRanger on May 14, 2021, 11:51:24 pm
That's a fuckton of work though. Like a whole new sub-game.

I'd still just advocate for modders to implement more aggressive surrender conditions if they find simple missions too tedious.
Title: Re: Auto-Battle
Post by: spawi on May 16, 2021, 07:02:38 am
Oh yeah, don't get me wrong, I know it is a lot of work. But this can be developed iteratively. My goal was to brainstorm some ideas, to maybe make Meridian et al. see more potential in this line of thinking. But of course, just an idea :)
Title: Re: Auto-Battle
Post by: Skullar on July 25, 2021, 05:56:37 am
On one side I feel like it would be fun to watch the AI handling my soldiers just for giggles, but on the other hand it would drive me nuts the moment it makes a single wrong move, and there is room for too many wrong steps, I would like to try it out to just enjoy the pleasure of watching my units display autonomy for once, sounds fun, but yeah, it would be really hard to make it work in a successful way I guess