I’m trying to create a system by which people are related to other people based on their familial connections. This worked out well for a while, but after introducing Uncleship, it doesn’t quite work. That is, the uncles don’t quite list all their nephews and the nephews don’t list the uncles. I have a good idea why this is happening, but it seems like its gonna take a good bit of seemingly redundant code in my ‘calculate relations’ function. I was wondering if anyone has any advice/tips/shortcuts. I looked in the Public Library, and I didn’t see this functionality. If there is already an extension for it, that’d be great. Pretty much any help is appreciated. Anyways, here’s the code:
[code]Marriage relates one person (called spouse) to another.
The verb to be married to means the marriage relation.
Paternity relates various people to various people.
The verb to be the parent of means the paternity relation.
The verb to be the child of means the reversed paternity relation.
Fraternity relates people to each other in groups.
The verb to be siblings with means the fraternity relation.
Grandpaternity relates various people to various people.
The verb to be the grandparent of means the grandpaternity relation.
The verb to be the grandchild of means the reversed grandpaternity relation.
Cousinship relates people to each other in groups.
The verb to be cousins with means the cousinship relation.
Uncleship relates various people to various people.
The verb to be the uncle of means the uncleship relation.
The verb to be the nephew of means the reversed uncleship relation.
Definition: A person is married rather than single if their spouse is a person.
Workspace is a room.
Kelsey is a woman in Workspace.
Alex is a man in Workspace.
Kelsey is the child of Catherine.
Stanton is the child of Kelsey.
Catherine is the child of Frances.
Stuart is the child of Frances.
Richard is the child of Frances.
Debbie is married to Richard.
Kelsey is the child of Chuck.
Kelsey is married to Alex.
Dale is married to Miriam.
Carl is siblings with Dale.
Alex is the child of Dale.
Travis is the child of Dale.
Stephen is siblings with Travis.
Alex, Stuart, Richard, Dale, Stephen and Travis are men.
Kelsey, Catherine, and Debbie are women.
When play begins:
calculate relatives;
repeat with John running through people:
say “[bold type][John][roman type]:[line break]”;
say “Spouse: [spouse of John][line break]”;
say “Parents: [list of people who are the parent of John][line break]”;
say “Children: [list of people who are the child of John][line break]”;
say “Sisters: [list of women who are siblings with John][line break]”;
say “Brothers: [list of men who are siblings with John][line break]”;
say “Grandparents: [list of people who are the grandparent of John][line break]”;
say “Grandchildren: [list of people who are the grandchild of John][line break]”;
say “Aunts: [list of women who are the uncle of John][line break]”;
say “Uncles: [list of men who are the uncle of John][line break]”;
say “Nieces: [list of women who are the nephew of John][line break]”;
say “Nephews: [list of men who are the nephew of John][line break]”;
say paragraph break;
To calculate relatives:
repeat with John running through people:
if John is married to someone (called the parent):
now every person who is the child of John is the child of the parent;
if John is the parent of someone (called the child):
now every person who is the child of John is siblings with the child;
repeat with John running through people:
if John is married to someone (called the parent):
now every person who is the child of John is the child of the parent;
if John is the parent of someone (called the child):
now every person who is the child of John is siblings with the child;
repeat with grandpa running through people who are the parent of John:
now grandpa is the grandparent of every person who is the child of John;
repeat with unky running through people who are siblings with John:
if unky is not John:
now unky is the uncle of every person who is the child of John;[/code]