Author Topic: [SOURCEMOD] Brutal-OXCE 7.12.1  (Read 123308 times)

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.8.0
« Reply #405 on: November 21, 2023, 02:18:55 pm »
If you don’t have any ideas about identifying monsters that need to disable brutality by default (such as werecats), as a last resort, we can manually register them all and attach them as a base mod. I will still add it for XCF. But, of course, with new monsters we will need to constantly update the list and this is not very convenient.
I had an idea and it is implemented via the "Brutal Brutes"-option.
The idea was to say: "If the unit doesn't have an inventory, it's dumb". The rationale was: "Having an inventory indicates some sort of intelligence to use and manage items."

However, while this was consistent for vanilla-UFO, when I looked at how XCF does it, I found that the parameter which is part of the armors.rul usually is left at the default, which is to have an inventory.

But this would be the way to control it right now. So it's not the lack of an idea but the lack of something that is also reliable in that regard.

Other than that the reverse-logic can be used. Disable Brutal-AI in options and enable it for all units in units.rul.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.8.0
« Reply #406 on: November 21, 2023, 02:28:48 pm »
I mentioned the pieces that may be done by editing the mod definitions.  However, one of the approaches to solving these weapon definitions problems is to limit the weapon power through a parameter.  Basically, I'm asking if you think that a new parameter maxPower or similar could be added to that end.
I mean in theory something like that could be added. But the power of a weapon is clearly something that is data-driven and deliberately picked by the modder according to their intentions. An in-game-option to overrule weapon's power is possible but highly counter-intuitive for that purpose.
The proper way would be to create a submod that nerfs each weapon perceived as OP individually. There's also more elegant ways to do so than just hard-limiting their power-level. For example increasing the fire-rate while reducing the power-level to keep the damage against no armor the same while making it weaker against armor.

Offline Abyss

  • Colonel
  • ****
  • Posts: 355
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.8.0
« Reply #407 on: November 21, 2023, 07:47:53 pm »
Quote
1> Dynamic aggressiveness. => AI-controlled units dynamically adjust their aggressiveness based on their morale. The thresholds are:

= 100 => 4
= 83 => 3
= 67 => 2
= 50 => 1
<50 => 0

Will check this, sounds pretty interesting.
In general, this function of morale + some personified adjustments of soldier ranks would do super in terms of battles diversification.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.8.0
« Reply #408 on: November 22, 2023, 01:47:41 pm »
Will check this, sounds pretty interesting.
In general, this function of morale + some personified adjustments of soldier ranks would do super in terms of battles diversification.
I made an adjustment to how aggressivity 4 works yesterday. It now is distinct from the behavior expressed by Leeroy-mode.
The units will still walk towards where they think the enemy is. But when they think they are currently visible to the enemy, they will snap out of that and start considering cover. However, taking cover has a lower priority than attacking. So they will spend as many TUs as they can for attacking and only use whatever is left to break vision if possible.

I'd say that compared to the leeroy-mode this is actually a valid playstyle for confident units. It is very aggressive but still shows signs of intelligence.

If they are successful in doing that, their morale will keep high and they will continue doing it. Trying to put a swift end to the player's forces. If they notice they are taking losses, they will employ a more careful approach.

Offline Ronios

  • Sergeant
  • **
  • Posts: 27
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.8.2
« Reply #409 on: November 22, 2023, 07:29:45 pm »
Please tell me if there is any way for a player to arm grenades for the player and opponents automatically on turn 1, not 0? Or maybe you can add a turn 1 option to the automatic grenade arming option.

Usually, grenades in the game work completely outside of their role. It's essentially just an area weapon that doesn't necessarily need to hit and does more damage than most weapons. You can even come up, throw it at your feet and walk away.

I want to make grenades into grenades. So that their goal is to destroy shelters, scare enemies away and cause damage to those who simply remain in place.
There will be another option to pick it up and throw it back, or just put it in inventory, but this will also cost TU a lot and may have its own additional risks. And no one will write AI for this, so only the player will have access to this moment.

Well, yes, I'm tired of dynamites thrown from 20 squares, which are almost guaranteed to kill the whole team.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.8.2
« Reply #410 on: November 22, 2023, 09:03:56 pm »
There will be another option to pick it up and throw it back, or just put it in inventory, but this will also cost TU a lot and may have its own additional risks. And no one will write AI for this, so only the player will have access to this moment.
Code: [Select]
void AIModule::tryToPickUpGrenade(Tile *tile, BattleAction *action)
{
if (!_unit->hasInventory())
return;
for (BattleItem *item : *(tile->getInventory()))
{
if (item->isFuseEnabled())
{
if (_save->getBattleGame()->takeItemFromGround(item, action) == 0)
if (_traceAI)
Log(LOG_INFO) << "Picked up " << item->getRules()->getName() << " from " << tile->getPosition();
}
}
}
*cough*
No, you can't preprime automatically once you left the pre-battle stage. By using hotkeys you can to it relatively quickly manually though.
You can open the inventory drag it to the hand, hit tab and repeat until you're done.
Then you e-1-tab through all your units. The option "One click grenade-priming" needs to be enabled otherwise it needs an additional click. But yes, it requires TUs. You can also activate auto-play for one turn and hope it does prime a few grenades.

Other than that I'm not really sure what you are getting at with your post.
« Last Edit: November 22, 2023, 09:09:05 pm by Xilmi »

Offline Ronios

  • Sergeant
  • **
  • Posts: 27
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.8.2
« Reply #411 on: November 23, 2023, 06:05:04 am »
*cough*
No, you can't preprime automatically once you left the pre-battle stage. By using hotkeys you can to it relatively quickly manually though.
You can open the inventory drag it to the hand, hit tab and repeat until you're done.
Then you e-1-tab through all your units. The option "One click grenade-priming" needs to be enabled otherwise it needs an additional click. But yes, it requires TUs. You can also activate auto-play for one turn and hope it does prime a few grenades.

Other than that I'm not really sure what you are getting at with your post.
I apologize if I expressed my thoughts unclearly. I meant there was no way to quickly activate grenades. I want that during ACTIVATION, which is performed as usual, the timer for grenades is not set to 0 rounds (instantPrime: true ) (explosion at the end of the current team turn) and not to select how many rounds the timer will be. And so that it is placed strictly for 1 round for both the player and the AI.

Offline Juku121

  • Commander
  • *****
  • Posts: 1796
  • We're all mad here.
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.8.2
« Reply #412 on: November 23, 2023, 07:16:11 am »
Spoiler" Grenade offtopic":
It seems to me that most of the grenade changes are more of a ruleset thing rather than anything to do with AI.

Please tell me if there is any way for a player to arm grenades for the player and opponents automatically on turn 1, not 0? Or maybe you can add a turn 1 option to the automatic grenade arming option.
'fuseType: 1'


Honestly, the one-click priming option looks kind of like an end run around existing game mechanics and might actually be counterproductive, depending on mod and grenade.

Well, yes, I'm tired of dynamites thrown from 20 squares, which are almost guaranteed to kill the whole team.
'throwRange'

I was much happier once I changed all grenades to 'throwRange: 12' and big explosives to 'throwRange: 6' or even 'throwRange: 4'. So many people seem to think the absolutely unrealistic throwing ranges and accuracy are a core part of the OG X-Com experience... But I've ranted about this before. :(

I want to make grenades into grenades. So that their goal is to destroy shelters, scare enemies away and cause damage to those who simply remain in place.
Eh, IRL grenades don't really destroy cover. Some types (HE, dual-purpose, thermobaric) do degrade it, but the common frag grenade is exactly meant to be used from cover that will protect you and not the enemy.

X-Com doesn't really distinguish between frag and HE too well unless a modder is into it.
« Last Edit: November 23, 2023, 07:18:09 am by Juku121 »

Offline Ronios

  • Sergeant
  • **
  • Posts: 27
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.8.2
« Reply #413 on: November 23, 2023, 09:43:16 am »
Spoiler" Grenade offtopic":

It seems to me that most of the grenade changes are more of a ruleset thing rather than anything to do with AI.

'fuseType: 1'

Honestly, the one-click priming option looks kind of like an end run around existing game mechanics and might actually be counterproductive, depending on mod and grenade.
The one-click priming option can indeed break some grenades, but for the most part it’s more convenient.
'fuseType: 1' looks like a very interesting option. More digging into the ruleset, but this is really what I need.
'throwRange'

I was much happier once I changed all grenades to 'throwRange: 12' and big explosives to 'throwRange: 6' or even 'throwRange: 4'. So many people seem to think the absolutely unrealistic throwing ranges and accuracy are a core part of the OG X-Com experience... But I've ranted about this before. :(
And even more of ruleset. It will take some time, and I won’t notice everything right away, but setting it up is not a problem. Thank you very much for the good solution to both points.

Eh, IRL grenades don't really destroy cover. Some types (HE, dual-purpose, thermobaric) do degrade it, but the common frag grenade is exactly meant to be used from cover that will protect you and not the enemy.

X-Com doesn't really distinguish between frag and HE too well unless a modder is into it.
The game actually has problems distinguishing between what types of effects grenades can have. I think the closest variant of a frag grenade in the game is shrapnel, which weakly destroys the area, but is very good at breaking things and killing all living things.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.9.0
« Reply #414 on: November 25, 2023, 11:52:09 pm »
@Abyss:

Please check out the changes in 7.9.0.
I think they are something that could be interesting to you to toy around with.

Instead of going the route of randomly assigning old and new AI, I gave the new AI an adjustable chance to make a random move.

I did some experiments with highly inconsistent results.

I set up a game of X-Com with a rifle and a grenade for each soldier against lowest tech sectoids.
It also used Joy Narical's realistic accuracy.
X-Com was consistently using the maximum intelligence at aggressiveness of 3.
Sectoids had aggressiveness 2 but I tried it over and over which each of the intelligence levels.

The results were:

Int 0: 3
Int 1: 5
Int 2: 14 (1)
Int 3: 11
Int 4: 14 (0)
Int 5: 13

The number is how many X-Com Soldiers were killed. The number in brackets is the amount of aliens killed for the cases where X-Com lost.
I had first started with 5, then 0, then 3 then 1. Up until that point it follewed the expectations: The more intelligent the aliens are, the better their results.
But then came the test at Int 2, which was a total outlier. Int 2 means: 60% to make a random move and 40% to make what is considered the best move. With only 1 dead alien that seemed very unexpected.
At Int 4 (20% random, 80% best move) it achieved an even better result.

What this means is that the AI's supposed best moves still have potential to improve if some randomness can actually improve the result.

For melee-units I still need a reasonable idea. For them movement mostly is part of the attack-routine, which isn't impacted by the randomness. Basically they also move randomly when they can't attack a target. But when they can, they move towards it in order to do so. Making melee-units move randomly even if they could attack, would weaken them much more than ranged-units.

A big advantage of going this way instead of using vanilla-AI, is that we can make further adjustments to how exactly intelligence should impact their behavior.

Now with both aggression and intelligence optionally supported, there can be huge behavioral differences between units that modders have control over.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.10.1
« Reply #415 on: November 27, 2023, 10:31:30 am »
For 7.10 I finally implemented something that has been bothering me for a long time:

"Smart ctrl-click and auto-equip" => Ctrl-clicking items in the loadout-phase will prefer slots that are faster to reach. The off-hand will be deprioritized if the main-hand holds a two-handed item. Auto-equip uses the same logic.

With many soldiers dying, as is to be expected with Brutal-AI, equipping new soldiers is something that has to be done over and over. And while using equip-templates clearly helps, a little bit of perfectionism usually caused me to fill them to their capacity with stuff like additional grenades etc.

A fast way of doing so was to just ctrl-click these items on the ground and see how they made their way into the inventory... But what is this. After the belt is full, the stuff goes into the backpack... where it takes a lot of TUs to get it out. That's clearly suboptimal and cried for manual intervention.

Not anymore! The new feature introduced in 7.10 iterates through all inventory-parts and checks the amount of TUs needed to put it from there into the hands. Then it puts the item in the first slot with the lowest slot-to-hands-tu where it fits. This will also work with all sorts of custom/modded inventories.
Furthermore it looks whether the item in the main-hand is a two-handed-item and if not uses the other hand with priority.

So properly "filling up" new soldiers now is much less of a hassle.

Offline Abyss

  • Colonel
  • ****
  • Posts: 355
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.10.1
« Reply #416 on: November 28, 2023, 09:42:29 am »
Quote
Ctrl-clicking items in the loadout-phase will prefer slots that are faster to reach
Brilliant! Now it won't ignore quick-draw slots and would not throw everything into backpack.
I haven't thought QoL changes are area of your interests, thus never suggested something like that.

Quote
Intelligence-mode
0> Static intelligence. 1> Inherit intelligence from unit-intelligence. 2> Inherit intelligence from difficulty-level.

The second allows you to pick an intelligence-level for the case static intelligence was selected as Intelligence-mode:

Static intelligence
Chance to make a smart move instead of a random one: 0> 0% 1> 20% 2> 40% 3> 60% 4> 80% 5> 100%
Not sure it is clear from description what intelligence is and how it works.
Intel for each unit? Mean, current unit has a chance to deviate?
Intel of whole fraction? Like top-tier fractions are smart and some bandits are less smart?
Where exactly intel level of units is defined?
How exactly difficulty level affects intellegence? If I play hardest difficulty, will zombies and dogs use 100% smart moves instead of random/vanilla ones?


Quote
I set up a game of X-Com with a rifle and a grenade for each soldier against lowest tech sectoids.
It also used Joy Narical's realistic accuracy.
The more intelligent the aliens are, the better their results.
But then came the test at Int 2, which was a total outlier.
For statistically determined results there should be, at least, 100 rolls for every intel level. Nevertheless, this is quite interesting. I believe sometimes randomness can disrupt and counter AI expectations.
I would also suggest that AI shouldn't be taught on AI, but instead on human leather player playstyles. 
Hm. If there only was a battlefield move logger, then you actually can have a lot of materials to teach the AI from those who would love to contribute.
But as every new version make older one obsolete, logs should be pretty fresh. Is there a way to save the map and everything happening? Will it be massive? Will it actually help?

« Last Edit: November 28, 2023, 10:04:12 am by Abyss »

Offline psavola

  • Commander
  • *****
  • Posts: 816
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.10.1
« Reply #417 on: November 28, 2023, 10:12:16 am »
I'd really like to see QoL improvements make it into mainstream OXCE, to benefit also non-BAI users. But I suspect some of these might be contentious and non-trivial *), so I understand that this might not be a priority for Xilmi.

*) As examples:
 - Pre-prime right-clicking skipping the number of turns dialogue. I suspect 99,9 % of players would prefer this. But already someone has suggested something else. But I'd still wager this could be implementable in OXCE.
 - TU-efficient equipment placement. The right placement of items is affected by the order by which you add the items. Intelligent placement will only work to some degree if you assume the biggest and most relevant items are added first. Adding 1x1 sized objects to optimal places afterwards is a trivial (but very nice) improvement, and the big challenges arise when you place larger objects, the usefulness of which also depends on its purpose. So I could see that at least some improvements might be resisted in OXCE with an argument that doing so would create an endless need to finetune the placement algorithm.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.10.1
« Reply #418 on: November 28, 2023, 11:00:46 am »
Brilliant! Now it won't ignore quick-draw slots and would not throw everything into backpack.
I haven't thought QoL changes are area of your interests, thus never suggested something like that.
This isn't the first QoL-change I made. It's the third one actually:
1. One-click-grenade-priming
2. Manufacturing items only uses workshop-space once you actually start working on it and not alone by queuing it
3. The new smart-inventory usage

Basically whenever something really started to annoy me and could be solved with some code-changes I eventually ended up making these changes.

Not sure it is clear from description what intelligence is and how it works.
Intel for each unit? Mean, current unit has a chance to deviate?
Intel of whole fraction? Like top-tier fractions are smart and some bandits are less smart?
Where exactly intel level of units is defined?
How exactly difficulty level affects intellegence? If I play hardest difficulty, will zombies and dogs use 100% smart moves instead of random/vanilla ones?
Well, it is three different modes. So the answer to your questions is yes or no depending on what mode you choose.
The default mode is static intelligence. It is same for all enemies and you can set a value from 0 to 5 in the option right below it.
The second one is unit-intelligence, which is taken from the unit-types *.rul-file in the mod. The value that base AI uses for how many turns it can see the location of a spotted soldier. I think this is the one that should be most interesting for your purposes. Note that values can be higher than 5 for this. All units with an intelligence higher than 5 will also just express the most intelligent behavior. But I could also make adjustments and add more levels.
The third option is once again same for all enemies but depends on difficulty. Beginner = 1, Experienced = 2, Veteran = 3, Genius = 4, Superhuman = 5. With that brutal-ai shall become significantly easier on lower difficulty-levels.
Note that these modes are currently mutually exclusive but we could always add more modes if we can think of them.

For statistically determined results there should be, at least, 100 rolls for every intel level. Nevertheless, this is quite interesting. I believe sometimes randomness can disrupt and counter AI expectations.
I would also suggest that AI shouldn't be taught on AI, but instead on human leather player playstyles. 
I know, statistical relevance of one test-run is pretty low. That's also not training the AI based on itself, that's just benchmarking. For benchmarking it, I need something that is constant and something that isn't. My own play obviously would deviate, the AI with a static setting should act the same every time.

The teaching-process mostly is based on observing every move and thinking about whether I would have done the same and if not, look at what information the AI could have concluded by that doing what it did wasn't a good move. However, with so many different modes to set the AI up, a lot of those do not fulfill the "how would I play"-criteria.

Hm. If there only was a battlefield move logger, then you actually can have a lot of materials to teach the AI from those who would love to contribute.
But as every new version make older one obsolete, logs should be pretty fresh. Is there a way to save the map and everything happening? Will it be massive? Will it actually help?
Enabling the traceAI-option in options.cfg logs all the moves and also parts of the "thought-process" of the AI in the log. But this is very dependant on context. A lot of the contents of that log are only ever useful if at the same time I have the map open so I can see what coordinates corresponds to what position. A mere log of what they do without seeing the map would be next to useless. A log of what the player has done even more so.

What actually would help is gameplay-footage in the form of videos, ideally with the player describing their thought-process. Especially on relatively even grounds. Someone showing me what they do and why would allow me to see whether there's something I haven't considered yet.

Rereading what you wrote seems like you mean some sort of replay-mode. That would also help if it existed, I suppose but it would lack the explanatory elements of a narrated video. It is possible to learn just by observation but learning by the combination of observation and being told the reasoning would be a lot more efficient.

Offline Xilmi

  • Moderator
  • Commander
  • ***
  • Posts: 641
    • View Profile
Re: [SOURCEMOD] Brutal-OXCE 7.10.1
« Reply #419 on: November 28, 2023, 12:38:32 pm »
I'd really like to see QoL improvements make it into mainstream OXCE, to benefit also non-BAI users. But I suspect some of these might be contentious and non-trivial *), so I understand that this might not be a priority for Xilmi.
It wasn't my idea to have a separate repository. It's the result of the OXCE-team not wanting experimental-changes, even if those are completely optional. These requirements were incompatible with AI-development, which is an iterative process.

There's also others who tried to get their changes into OXCE and who were told off. Flaubert and Joy Narical for example. So their features are also exclusive to Brutal-OXCE.

The effort of creating a pull-request towards OXCE for small secluded features like that isn't really all that big. But with the always looming chance of rejection, I won't even bother. And of course there's also the point that I want to see let's players play against my AI, so if I can incentivize more people to use my client by offering some exclusive features besides the AI, chances are higher they will want to use my client and try out the AI too, if it's just one click away.

Also I don't mind if the OXCE-Team backports anything they want from Brutal-OXCE. So if they want any of my QoL-changes, they can just take them. It's what I do with Joy Narical's stuff too.

Intelligent placement will only work to some degree if you assume the biggest and most relevant items are added first. Adding 1x1 sized objects to optimal places afterwards is a trivial (but very nice) improvement, and the big challenges arise when you place larger objects, the usefulness of which also depends on its purpose.
It is indeed as you say. If you don't start with the main-weapon but for example a medikit, it will put the medikit into a hand-slot because the hand-slot is still free and according to the algorithm the hand-slot is the fastest slot to take something into your hands from because the TU-cost for that is 0 since it's already there. The algorithm just assumes you start from the most important and work down to the least important item.

So I could see that at least some improvements might be resisted in OXCE with an argument that doing so would create an endless need to finetune the placement algorithm.
Yeah, as I said, this is a real risk but at this point not even my main reason not to try it.