Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship/kin thought weights | Option to save dead relationships #2476

Open
wants to merge 29 commits into
base: development
Choose a base branch
from

Conversation

Snowstar38
Copy link
Contributor

@Snowstar38 Snowstar38 commented Jun 16, 2024

About The Pull Request

When generating cat thoughts, there will now be a chance for the other_cat to be a cat that they already have a relationship with, or one they are related to (determined by relationship_thought_chance and kin_thought_chance).

  • Default settings are 20% relationship/20% kin, so 60% of other_cats for thoughts will still be pure RNG.
  • The chance is for setting other_cat, not whether or not a thought will actually MENTION another cat, so the actual % of thoughts the player sees that contain a related cat's name will be lower.

In addition, an option (dead_relations) was added in the clansettings to enable retaining dead cats' relationships. This is false by default. The reason these two changes are bundled is because when dead_relations is enabled, dead cats can now have relationship thoughts rolled, so they will have a chance to think about cats they were friends with before dying.

This also fixes a bug I discovered during testing in which some cousins would not properly be displayed in the family tree (now cousins aren't checked until the full list of aunts and uncles is complete).

Why This Is Good For ClanGen

Thoughts are one of the main ways to get insight into the day-to-day lives of the cats in your Clan. Oftentimes, cats in Clangen can feel a bit disconnected with one another, especially in larger Clans; while there is a relationship and kin system, it has no impact on who they're thinking of. This change will hopefully make the Clan feel more "alive" by allowing cats' connections to affect thoughts.

It also makes dead cat thoughts more interesting, as now a dead cat is more likely to be thinking of their kin (or friends, if dead_relations is enabled) left behind in the living world.

Allowing dead cats to retain their relationships is a commonly requested feature; it is by default off and includes a tooltip warning mentioning possible performance impacts on large Clans (though it's not clear if this impact would be all that significant). Keeping that information is valuable for those who like to look back through their cats in StarClan and the Dark Forest and remember who they were friends or rivals with.

Proof of Testing

image

Changelog/Credits

Big changes:

  • Added relationship-based and kin-based thought weights to make cats more likely to think about cats they already know or are related to, with the weights being adjustable in the config file
  • Added a Clan setting, dead_relations (default: false), that saves and displays dead cats' relationships when enabled in the Clan settings page

Technical changes:

  • Added a helper function called get_kin_groups to utility.py
  • Added get_uncle_aunts, get_cousins, and get_grandkits, which are extremely similar to other get_relative functions
  • Added get_distant_kin and recursive_get_relatives so we can gather cats from further away on the family tree, generally excluding "in-laws" and cousins of cousins
  • Added two game_config settings, relationship_thought_chance and kin_thought_chance, to choose the % of thoughts that will be of that type (default: 20%)

Bugfix:

  • Fixed an issue with init_cousins where cats were being checked as cousins before all aunts and uncles had been added to the parents_siblings list, resulting in some cousins not appearing in the family tree under certain circumstances

@scribblecrumb scribblecrumb requested a review from Lixxis June 25, 2024 03:00
@Ryos00 Ryos00 self-requested a review July 11, 2024 18:13
@Ryos00 Ryos00 requested a review from scribblecrumb July 11, 2024 18:15
Copy link
Collaborator

@Lixxis Lixxis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor things I found, the files cat.py and load_cat.py I still have to look at (when I have more brain power)

scripts/game_structure/game_essentials.py Outdated Show resolved Hide resolved
scripts/utility.py Outdated Show resolved Hide resolved
scripts/utility.py Outdated Show resolved Hide resolved
@Snowstar38 Snowstar38 requested a review from Lixxis October 28, 2024 00:06
# since we rolled a special thought already and couldn't get one
thought_choices_reroll = ['kin', 'normal']
weights_reroll = [
(1.25 * game.config["relationship"]["kin_thought_chance"]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there still a multiplication when there is a setting for the chance? The reason for the settings is to reduce such values as much as possible.

(same as in other lines such as 1733)

}

kin = {
"gen_grandparents": [cat.all_cats.get(cat_id) for cat_id in cat.all_cats if cat.all_cats.get(cat_id).is_grandparent(cat)],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "get_kin_groups" function is not very performant. To improve it at least a little add the new "kin" to the inheritance class. It seems it was done but not used?

@@ -1665,6 +1665,43 @@ def change_relationship_values(
if log_text not in rel.log:
rel.log.append(log_text)

def get_kin_groups(cat, include_dead=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it important at this point to already have the cat class? It would be more performant to just use the id's as long as possible and then fetch the cat, when the information from them is needed.

close_kin, kin, distant_kin = get_kin_groups(self, include_dead=include_dead)

# 50% chance of choosing close kin
if kin_group_choice >= 50:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chances of each type of kin group can and should also be added in the settings.

chosen_cat = choice(distant_kin_cats)
other_cat = chosen_cat.ID
#print("distant kin thought: from: ", self.name, " to: ", chosen_cat.name)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'else: pass'
sections doesn't change anything and should be removed.

break
# for dead cats
# Roll relation and kin thought chances
if thought_type == 'relationship':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thought type should be handled before the "if where_kitty == " statement. In that way there won't be that many code duplications in the class.

@Lixxis
Copy link
Collaborator

Lixxis commented Dec 20, 2024

@Snowstar38 Sorry that it (to be specific I) took so long (also there was the feature freeze in between)
I have some comments to address + there is as well a merge conflict which should be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants