Enhance family and roster management in school simulation by implementing support for incomplete families, ensuring proper handling of absent parents while maintaining surname consistency. Update family creation logic to account for single-parent households and revise child identification to prevent ID conflicts. Introduce seat shuffling to prevent siblings from being placed in the same class, improving the realism of student distribution. Update related tests to validate these new functionalities and ensure robustness in family and roster handling.
ci / server (push) Failing after 3m49s
ci / client (push) Successful in 24s

This commit is contained in:
Leonid Pershin
2026-08-18 21:13:16 +03:00
parent 7f6852548d
commit 3366e8e44b
19 changed files with 766 additions and 90 deletions
+22 -3
View File
@@ -3,12 +3,31 @@ namespace HSchool.People;
internal readonly record struct FamilyPlan(int FamilyIndex, IReadOnlyList<PupilSeat> Seats);
/// <summary>
/// Walks seats in order and groups them into families of 13. A short remainder becomes
/// singleton families rather than shrinking an earlier family's intended size, so a longer
/// seat list only appends families.
/// Walks seats in order and groups them into families of 13, taking a run of consecutive seats
/// per family. Callers hand in a shuffled seat list — a run of *adjacent* seats is one classroom,
/// which would put every sibling in the same class.
///
/// A family whose intended size does not fit the remainder takes one seat instead of shrinking,
/// so growing the seat list only disturbs the tail.
/// </summary>
internal static class FamilyPlanner
{
/// <summary>
/// One child per family. Used by the yearly intake: every seat there is a first-year seat, so
/// grouping would hand a family two or three same-age children at once. An arriving pupil who
/// does have an older sibling gets attached to that family instead.
/// </summary>
public static IReadOnlyList<FamilyPlan> Singletons(IReadOnlyList<PupilSeat> seats, int startIndex)
{
var plans = new FamilyPlan[seats.Count];
for (var i = 0; i < seats.Count; i++)
{
plans[i] = new FamilyPlan(startIndex + i, [seats[i]]);
}
return plans;
}
public static IReadOnlyList<FamilyPlan> Plan(int schoolSeed, IReadOnlyList<PupilSeat> seats, int startIndex = 0)
{
var plans = new List<FamilyPlan>();