Persist talk opinions and pick topics by weight.

A finished circle never set Tick's peopleChanged bit, so people.json kept pre-talk numbers until morning drift. PickTopic compared a 0..total roll to a 0..1 cursor, so gossip almost never changed the subject.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 13:34:34 +03:00
co-authored by Cursor
parent 8d07b3606d
commit b38d0bb628
9 changed files with 298 additions and 2 deletions
@@ -63,6 +63,22 @@ public class MorningOpinionsTests
Assert.True(after < before);
}
[Fact]
public void DriftToZero_DropsTheRecord()
{
using var school = OpenStaffed();
var child = school.Roster!.People.First(person => person.IsStudent && !person.IsParent);
var classmate = school.Roster.People.First(person =>
person.IsStudent
&& !person.Id.Equals(child.Id, StringComparison.Ordinal)
&& !OpinionStore.FamilyMemberIds(school.Roster, child).Contains(person.Id));
var drift = school.Catalog!.BehaviorRules!.OpinionDriftPerMorning;
OpinionStore.Set(child, classmate.Id, Math.Min(2, drift));
Assert.True(MorningOpinions.Apply(school));
Assert.False(child.Opinions.ContainsKey(classmate.Id));
}
private static void AdvanceTo(School school, DateTime until)
{
while (school.Clock.Time < until)