Author Topic: General Discussion  (Read 3821898 times)

0 Members and 20 Guests are viewing this topic.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #9165 on: December 17, 2016, 11:50:20 AM »
Yeah, it's a bit confusing in code but the concept itself is not difficult to explain and should be flexible enough to milk it in the future. It has not passed players test yet thought as it was added after alpha release :(
Like what we're doing?

Offline picobyte

  • Jr. Member
  • **
  • Posts: 75
Re: General Discussion
« Reply #9166 on: December 17, 2016, 12:52:42 PM »
Here Xela outlined his skills concept in general.

thanks. FYI: I'm rewriting the auto_equip() to try and make a better decision based on stat and skill bonusses/penalties per item. A question I have is how we should weigh stat mods versus skills mods.
To make them comparable I think I could normalise (scale) them by their respective max values, or should a stat increase e.g. always outweigh a skill benefit?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #9167 on: December 17, 2016, 01:12:42 PM »
A question I have is how we should weigh stat mods versus skills mods.
To make them comparable I think I could normalise (scale) them by their respective max values, or should a stat increase e.g. always outweigh a skill benefit?
Skills have super high max values, almost unobtainable without cheats. Dunno how are you going to normalize them  :D
And multipliers to action and training counters don't have big maxes but are very, very useful, especially in the long run.

Possible ideas:
- use item price to figure out which item is more powerful when in doubt
- items with bonuses to skill counters > items with bonuses to skill > items with no bonuses to skill
- check how useful the item with stats for the character; if it gives charisma+50, but current charisma is 49/50, it's useless compared to any item with skill bonuses.
« Last Edit: December 18, 2016, 02:29:56 AM by DarkTl »

Offline picobyte

  • Jr. Member
  • **
  • Posts: 75
Re: General Discussion
« Reply #9168 on: December 17, 2016, 01:43:23 PM »
multipliers to action and training counters don't have big maxes but are very, very useful, especially in the long run.

The general idea was: calculate exactly for each item what the resulting target stats and skills will be and equip the item based on that. This includes the diminished action value beyond training penalty calculation and only counting until max is reached.

Code: [Select]
         for item in itemlist:

                if item.slot != slot or not item.eqchance or item.type == "permanent" or item.ceffect or item in skip:
                    continue

                if item.id in self.consblock or item.id in self.constemp or not can_equip(item, self):
                    continue

                if slot == "consumable":
                    if item.type == "alcohol" and self.effects['Drunk']['activation_count'] >= 30:
                        continue

                    if item.type == "food" and elf.effects['Food Poisoning']['activation_count'] >= 6:
                        continue
                    next_itemlist.append(item)

                weight = 0
                applicable = True
                for stat, value in item.mod.iteritems():

                    in_target_stats = True if stat in target_stats else False

                    if value < 0 and in_target_stats or stat in exclude_on_stats:
                        applicable = False
                        break

                    if in_target_stats:
                        # limit to remaining applicable for stat
                        weight += min(value, self.get_max(stat) - self.stats._get_stat(stat))

                if not applicable:
                    continue

                (stat_max_avg, stat_ct) = (0, 0)
                for stat, value in item.max.iteritems():

                    in_target_stats = True if stat in target_stats else False

                    if value < 0 and in_target_stats or stat in exclude_on_stats:
                        applicable = False
                        break

                    if in_target_stats:

                        stat_max = self.get_max(stat)
                        stat_max_avg += stat_max
                        stat_ct += 1
                        stat_remaining = stat_max - self.stats._get_stat(stat)

                        # if the max doesn't shift, at least give a weight up to 1 for the increased max.
                        # if max decreases, give a penalty, more severe if there is little stat remaining.
                        weight = value / (stat_remaining + min(value, 1)) # stat_remaining is >= 0

                        # if stat increases due to shifted max, weight accordingly
                        weight += item.get_stat_eq_bonus(self, stat)

                if not applicable:
                    continue

                # for normalisation
                stat_max_avg = stat_max_avg / stat_ct if stat_ct else 1

                for skill, effect in item.mod_skills.iteritems():

                    in_target_skills = True if skill in target_skills else False

                    if value < 0 and in_target_skills or skill in exclude_on_skills:
                        applicable = False
                        break

                    if in_target_skills or value < 0 and skill in exclude_on_skills:

                        skill_max = SKILLS_MAX[key]

                        skill_remaining = skill_max - self.get_skill(skill)
                        if skill_remaining <= 0:
                            # calculate skill with mods applied, as in apply_item_effects() and get_skill()

                            mod_action = self.stats.skills[0] + effect[3]
                            mod_training = self.stats.skills[1] + effect[4])
                            mod_skill_multiplier = self.stats.skills_multipliers[2] + effect[2]

                            training_range = mod_training * 3
                            beyond_training = mod_action - training_range

                            if beyond_training >= 0:
                                mod_training += training_range + beyond_training / 3.0
                            else:
                                mod_training += mod_action
                            new_skill = mod_training*max(min(mod_skill_multiplier, 1.5), 0.5)

                            stat_scale = stat_max_avg / skill_max
                            if in_target_skills:
                                # limit to remaining applicable for skill
                                weight += min(new_skill, skill_remaining) * stat_scale
                            else:
                                weight += value * stat_scale

                if not applicable:
                    continue

Offline picobyte

  • Jr. Member
  • **
  • Posts: 75
Re: General Discussion
« Reply #9169 on: December 17, 2016, 01:59:29 PM »
..and this is work in progress. the general idea search which item gives the max weight, and apply that. Only one except consumables, reiterate consumables until the benefit and costs outweigh consumption.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #9170 on: December 17, 2016, 01:59:57 PM »
Strictly speaking, auto equipment does not have to be completely perfect all the time. It should be adequate, but a perfect one will make the option to directly access character inventory (slaves and lovers) mostly useless.

Offline picobyte

  • Jr. Member
  • **
  • Posts: 75
Re: General Discussion
« Reply #9171 on: December 17, 2016, 02:24:00 PM »
Strictly speaking, auto equipment does not have to be completely perfect all the time. It should be adequate, but a perfect one will make the option to directly access character inventory (slaves and lovers) mostly useless.

That's a good point, but it it may be a good starting point though. We could add randomness and let eqchance, price and badness weigh. And some more trait based preferences.
« Last Edit: December 17, 2016, 02:32:36 PM by picobyte »

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #9172 on: December 17, 2016, 04:14:55 PM »
Yeah, especially at first, plan was to pick based on occupations and eqchance. We may have a lot more information with jobs implementation in the future.
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #9173 on: December 18, 2016, 02:30:08 AM »
Xela, there is a small but pesky limitation at the MC setup screen. If the second class is tied to the third choice, ie MC mother, you cannot see it until you pick one of options from the last choice.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #9174 on: December 18, 2016, 03:25:52 AM »
I'll take a look at it when I can.
Like what we're doing?

Offline picobyte

  • Jr. Member
  • **
  • Posts: 75
Re: General Discussion
« Reply #9175 on: December 18, 2016, 06:17:39 PM »
Ok I have an  auto_equip() that works to some extent. In my branch for now. In case anyone wants to look at it, maybe just review the result here. In the beginning I started with modifying the existing code, but after a while I thought it best to simply replace it.

as the commit message states: In this version an attempt is made to get the 'perfect' auto_equip - later trait and random driven deviations from this perfect selections are planned, some of which are already present as commented code.

There are also some patches that touch core functions. I've made them small enough for review and so that I'm confident that they do the right thing. They were committed on and after December 17th.

There were a few pytgroup and other bugfixes.
I've added a unequip all button to the inventory screen.
« Last Edit: December 18, 2016, 06:21:39 PM by picobyte »

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #9176 on: December 18, 2016, 06:48:14 PM »
Sounds nice!

Can you add two or three setups for inventory that could be stored? It was requested by a bunch of people during the alpha release phase. Basically you just have to store equipped dicts and add checks to make sure that if an item was sold or given away (no longer in inventory). Also it should unequip current equipped items before equipping the saved preset.

The reason it was asked is that they wanted a combat/interactions/work oriented setups and wished to conveniently toggle between them, which sounds like a perfectly reasonable request. It's prolly the last thing from alpha suggestions that we didn't add to the game or did not make plans to implement.


I can't check the auto-equip atm, but if it feels like it's doing the right thing, it's a good design. Stuff like that can be improved almost indefinitely and it's almost always a bad idea to try and make it ultra smart.
Like what we're doing?

Offline picobyte

  • Jr. Member
  • **
  • Posts: 75
Re: General Discussion
« Reply #9177 on: December 18, 2016, 07:27:32 PM »
Thanks. I think that should be not too hard.

Can you add two or three setups for inventory that could be stored? It was requested by a bunch of people during the alpha release phase. Basically you just have to store equipped dicts and add checks to make sure that if an item was sold or given away (no longer in inventory). Also it should unequip current equipped items before equipping the saved preset.

Storage of equip dicts per person, and I guess somewhere saved in the inventory screen, and maybe add a [1] [2] [3] button to swap in the character listing, if a person has it.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #9178 on: December 19, 2016, 10:47:55 AM »
The reason it was asked is that they wanted a combat/interactions/work oriented setups and wished to conveniently toggle between them, which sounds like a perfectly reasonable request.
It's a bit tricky though due to design-based limitations. For example, slaves cannot have a combat setup because they cannot equip most weapons and armors. And unless the character is a slave or a lover, you don't have direct access to inventory, so the same should be true for her setups.

Offline picobyte

  • Jr. Member
  • **
  • Posts: 75
Re: General Discussion
« Reply #9179 on: December 19, 2016, 11:21:41 AM »
It's a bit tricky though due to design-based limitations. For example, slaves cannot have a combat setup because they cannot equip most weapons and armors. And unless the character is a slave or a lover, you don't have direct access to inventory, so the same should be true for her setups.

I have something that works now. The equipment is stored per person and from an equiped state, so unless the character has a status change, this cannot be an issue. What is not yet implemented is the checks for discarding and selling items. Where should these checks occur?

I pushed the changes in the main branch, so you can see the results for yourself.