Author Topic: [DONE][Suggestion] Inventory auto-placement priorities/rules  (Read 9101 times)

Offline Derived

  • Sergeant
  • **
  • Posts: 10
    • View Profile
[DONE][Suggestion] Inventory auto-placement priorities/rules
« on: February 10, 2020, 12:37:43 am »
Problems with current mechanics of quick equip (CTRL-clicking items in inventory):
- when belt is full, items are placed in backpack
- pistols are placed in backpack even if they would fit to the belt
- high explosives rapidly block pistol slots from belt
- items are not prioritized to the slot where in-combat use (moving it to hand) is fastest.

Thus here is a change for:

    priority order:
    * place item into hand slot using previous rules
    * shoulder slots (3 TimeUnits)
    * leg slots if 2 wide item (e.g. high explive) (4TU)
    * belt (4TU)
    * leg slots (4TU)
    * backpack (8TU)
    * where-ever it fits (custom mods may have other slots, so just iterate all of them)

Some mods may cause this to be suboptimal, though.

Edit 2020-02-12: attached patches updated.
Edit 2020-02-22: small tweaks, patches updated
Edit 2020-02-24: clarified that this patch doesn't change how quick-equip works if current code placed item into a hand slot
« Last Edit: February 19, 2023, 11:04:25 am by Meridian »

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Re: [improvement] Change inventory quick-equip priorities
« Reply #1 on: February 10, 2020, 06:59:16 am »
Right what i ever missed. Thank you.

Offline Derived

  • Sergeant
  • **
  • Posts: 10
    • View Profile
Re: [improvement] Inventory priorities
« Reply #2 on: February 22, 2020, 11:25:37 pm »
Things I still may want to do before submitting for merging:
- Test using also other mods than Final mod pack.
- Handle optimal item placement better when there are modded custom slots.
- Optimize ammo placement reload, other items for grabbing to other hand

I guess the absence of a "No" post from Meridian is a good sign :)
« Last Edit: February 22, 2020, 11:38:36 pm by Derived »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: [improvement] Inventory priorities
« Reply #3 on: February 23, 2020, 08:51:18 am »
I guess the absence of a "No" post from Meridian is a good sign :)

I didn't answer, because there is no question anywhere.
(also, absence of feedback is usually a bad sign)

As for the feature, this is an unsolvable problem... actually, I think it doesn't even qualify as a problem, because you can't clearly define the requirement.
So, from my side a clear no.

There is no such thing as "optimal placement", every person has completely different preferences, just check a few LPers.
Even the same person has different preferences in different situations.
Or even same situation, just wearing different armor.
Or playing a different mod.
Or or or...

Not to mention vanilla purists coming at you with pitchforks and torches.

Offline Derived

  • Sergeant
  • **
  • Posts: 10
    • View Profile
Re: [improvement] Inventory priorities
« Reply #4 on: February 23, 2020, 12:00:22 pm »
Others have expressed some interest and I have a working proof-of-concept, so let's see if this is salvageable?

I've outlined some problems with current placement priorities in the first post. What I'm looking for is a smoother playing experience for most play-styles (including yours). Yes, "optimal placement" is impossible, so let's just call it better placement.

For trying to come up with a cohesive requirement for can I assume:
- Items are equipped to be used?
- Lower TU cost to using an item is better?
- Current heuristic for when to place the item in a hand slot is good?

Quick-equip is not a vanilla feature, right? So changes shouldn't be a problem from a purist point of view?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: [improvement] Inventory priorities
« Reply #5 on: February 23, 2020, 02:44:23 pm »
For trying to come up with a cohesive requirement for can I assume:
- Items are equipped to be used?

Not always, there are passive items, which you just need to have in the inventory to work.

- Lower TU cost to using an item is better?

Yes, but you use more than just one item... which one gets priority for the "best" slot?

- Current heuristic for when to place the item in a hand slot is good?

As many opinions on this as there are people on Earth.
I just saw Quickmind complaining about it (twice) on yesterday's stream.

Quick-equip is not a vanilla feature, right? So changes shouldn't be a problem from a purist point of view?

Nope, it's vanilla.
You can also try to PR vanilla, if you convince them, it would be automatically merged into OXCE...

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11727
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [improvement] Inventory priorities
« Reply #6 on: February 23, 2020, 03:00:45 pm »
Indeed various people have different priorities. Still, I think a good common ground would be one simple rule: don't put into backpack any stuff which fits on the belt, unless there is no space.

Offline Rubber Cannonball

  • Colonel
  • ****
  • Posts: 195
    • View Profile
Re: [improvement] Inventory priorities
« Reply #7 on: February 24, 2020, 01:23:06 am »
Instead of trying a one size fits all approach, what about a more adaptive method that looks at how the player has previously equipped soldiers and the saved templates (s)he created.  I suspect this would better reduce the amount of rearranging the player would have to do in a game.  And it would adjust itself to the mod, the player's style, and new items as the player progresses through a game.  IIRC, every soldier's last loadout is saved as well as the player saved loadout templates.

I don't think a fixed priority order approach will work well.  I for one in x-piratez, tend to pick my primary weapon as one of the last items equipped.  I'll start with the previous loadout for the soldier or load a template, strip it down to what will be mostly common and copy/paste to other soldiers.  Then I'll go back through and finish them up.  I find the autoequip that occurs if i leave a soldiers inventory empty to be completely worthless in x-piratez.  In vanilla, I could probably just get by with the templates.

Offline Derived

  • Sergeant
  • **
  • Posts: 10
    • View Profile
Re: [improvement] Inventory priorities
« Reply #8 on: February 24, 2020, 06:06:03 pm »
Not always, there are passive items, which you just need to have in the inventory to work.

Default such items to backpack / slowest to access slot. But maybe such a corner case it won't be a problem? Also see next assumption.

Yes, but you use more than just one item... which one gets priority for the "best" slot?

Assume player start equipping with items intended for best slots.

As many opinions on this as there are people on Earth.
I just saw Quickmind complaining about it (twice) on yesterday's stream.

Any improvement suggestions that could be added as well?

Nope, it's vanilla.

How about binding to ALT-click, leaving the vanilla CTRL-click as is?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: [improvement] Inventory priorities
« Reply #9 on: February 24, 2020, 06:38:27 pm »
As I said, everyone has different expectations, and I don't see why I would add a feature to cover specifically your expectation, no offense intended.

I can be wrong, but that's how I see it.
« Last Edit: February 10, 2024, 03:54:58 pm by Meridian »

Offline Derived

  • Sergeant
  • **
  • Posts: 10
    • View Profile
Re: [improvement] Inventory priorities
« Reply #10 on: February 24, 2020, 08:35:35 pm »
I don't think a fixed priority order approach will work well.  I for one in x-piratez, tend to pick my primary weapon as one of the last items equipped.

Only solution I can think of is that the first equipped weapon is primary, as there always won't be a secondary. Do note that right hand is only ever prioritized for quick-equip of a weapon. Other items are not placed there.

Instead of trying a one size fits all approach, what about a more adaptive method that looks at how the player has previously equipped soldiers and the saved templates (s)he created.
Building an intelligent quick-equip / autoequip would be a larger huge task.
- It would try to learn based on your corrections, saved templates, previous loadouts, available equipment, armor and soldier attributes. That is a lot of variables.
- It would require some kind of AI/neural network.
- AIs always need very large data-sets and learn very slowly. Especially when there are lots of variables. Your play-style will probably evolve faster than any possible AI can learn, resulting in a feature even more useless than the current auto-equip.

I had an idea based on this, though.
- From previous loadouts, use the best matching for auto-equip. This "best match" cost function being somehow weighted with all relevant variables and limitations.
Problems with even this:
- Would be pretty hit-and-miss, even if your playstyle has clearly defined soldier roles.
- Preserving all previous at-combat-start-loadouts would be quite a bit of a size increase to the savefile.
- Defining a useful cost function would be very hard.

Auto-equip is hard. I think the only solution would be to hard code better logic than the current one. But as that wouldn't be vanilla and very subjective, it might not be something that Meridian would be prepared to merge.

As I said, everyone has different expectations, and I don't see why I would add a feature to cover specifically your expectation, no offense intended.

None taken. Vanilla quick-equip works according to your expectations?

I'm using this in my own custom build, but won't start releasing builds. I'm sharing changes here for the potential benefit to others.
« Last Edit: February 24, 2020, 10:28:04 pm by Derived »

Offline Rubber Cannonball

  • Colonel
  • ****
  • Posts: 195
    • View Profile
Re: [improvement] Inventory priorities
« Reply #11 on: February 24, 2020, 09:25:59 pm »
Only solution I can think of is that the first equipped weapon is primary, as there always won't be a secondary. Do note that right hand is only ever prioritized for quick-equip of a weapon. Other items are not placed there.
Building an intelligent quick-equip / autoequip would be a larger huge task.
- It would try to learn based on your corrections, saved templates, previous loadouts, available equipment, armor and soldier attributes. That is a lot of variables.
- It would require some kind of AI/neural network.
- AIs always need very large data-sets and learn very slowly. Especially when there are lots of variables. Your play-style will probably evolve faster than any possible AI can learn, resulting in a feature even more useless than the current auto-equip.

I had an idea based on this, though.
- From previous loadouts, use the best matching for auto-equip. This "best match" cost function being somehow weighted with all relevant variables and limitations.
Problems with even this:
- Would be pretty hit-and-miss, even if your playstyle has clearly defined soldier roles.
- Preserving all previous at-combat-start-loadouts would be quite a bit of a size increase to the savefile.
- Defining a useful cost function would be very hard.

Auto-equip is hard. I think the only solution would be to hard code better logic than the current one. But as that wouldn't be vanilla and very subjective, it might not be something that Meridian would be prepared to merge.

None taken. Vanilla quick-equip works according to your expectations?

I'm using this in my own custom build, but won't be releasing builds. I'm sharing here for the benefit of others.

I wouldn't expect an intelligent ai approach.  Merely more adaptive.  Also I wouldn't save all previous loadouts, just look at the ones currently saved.  I think every soldier the player has ever equipped has its last loadout saved.  By not saving earlier loadouts, the algorithm would actually adapt faster as the player progresses.  For instance if the saved loadouts have the vanilla stun rod (weapon) most often in the back pack then I would expect ctrl left click to stick it in the backpack even if it is the first item picked.  On mods that have pages and pages of items, I tend to pick items in the order I come across them.  If the motion scanner happens to appear in the right hand most often in the saved loadouts then the right hand should be the first slot tried when ctrl left clicking the scanner.


Actually I think I have a simpler, better idea:  Why not just have the mouse wheel scroll the ctrl-left clicked item through the available slots that it fits.
Edit:
Except for the hands, slots that are larger than the item should be last in the scroll order.
« Last Edit: February 24, 2020, 09:36:19 pm by Rubber Cannonball »

Offline Derived

  • Sergeant
  • **
  • Posts: 10
    • View Profile
Re: [improvement] Inventory priorities
« Reply #12 on: February 24, 2020, 10:22:12 pm »
If the motion scanner happens to appear in the right hand most often in the saved loadouts then the right hand should be the first slot tried when ctrl left clicking the scanner.

Good idea, tally up slots the item is placed in from existing loadouts. Prioritize slot selection based on that frequency. Giving highest priority to loadouts of units with same armor as the one currently being equipped.

This may even be partially adapted for auto-equip. At least it gives your preferences for where what kind of items should be equipped. Haven't looked into how auto-equip logic works, or even used it more than once, so I may be completely in the wrong.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: [improvement] Inventory priorities
« Reply #13 on: February 24, 2020, 10:57:30 pm »
Vanilla quick-equip works according to your expectations?

No, absolutely not.
I have auto-equip option turned off; and I use quick-equip (ctrl+click) pretty much only for dropping stuff on the ground, never for equipping stuff (maybe with a small exception every now and then for the main hand weapon).

To streamline equipment process, I have implemented the save/load equipment templates feature, which is what I use today.

Offline R1dO

  • Colonel
  • ****
  • Posts: 442
    • View Profile
Re: [improvement] Inventory priorities
« Reply #14 on: February 25, 2020, 01:02:51 am »
...
To streamline equipment process, I have implemented the save/load equipment templates feature, which is what I use today.

Which is probably the sane approach.

Trying to implement an AI (or supervised classification [1]) algorithm that takes into account the user preferences will require a lot of user input per modpack (since items tend to vary a lot between modpacks).

Most likely the computer will only converge to the users preferences (if at all) at the end of a playthrough.
And then you also have to take into account the following points:
* Amount of data that needs to be saved (e.g. what did the computer propose and what did the user override it with, per unique set of inputs).
* Research process (e.g. what was perfect for a certain stage will not be perfect for a later stage).

[1]
When first reading this topic this is what came to mind as a possible solution. I dismissed it as non-practical since the amount of possible solutions  could easily grow out of bounds.

-- edit --
Removed a statement which was based on a wrong assumption.
« Last Edit: February 25, 2020, 11:11:12 am by R1dO »