Enhance school day structure and decision-making for lunch breaks
ci / server (push) Failing after 3m43s
ci / client (push) Successful in 15s

- Updated `ai.md` to clarify the mechanics of hunger restoration and the importance of lunch breaks in the school schedule.
- Revised `schedule.md` to detail the new lunch break structure, allowing for separate sittings for different grade levels.
- Enhanced `Decision.cs` and `DecisionPlanner.cs` to incorporate logic for lunch breaks, ensuring that students only leave lessons during their designated lunch windows.
- Updated `DayFrameDef` and related classes to support multiple lunch breaks and validate their configurations.
- Adjusted tests to validate the new decision-making logic regarding lunch breaks and hunger management, ensuring robust functionality.
- Improved localization strings to reflect changes in the school day structure and lunch functionalities.
This commit is contained in:
Leonid Pershin
2026-08-19 23:17:16 +03:00
parent a441ed9763
commit 5eabc90d53
33 changed files with 831 additions and 404 deletions
+67 -2
View File
@@ -202,13 +202,77 @@ public class DecisionPlannerTests
Assert.Null(decision.StartAction);
}
/// <summary>
/// Lunch is a timetable, not an urge. Inside the sitting a pupil who is merely peckish still
/// goes; outside it a hungry one does not walk out of the corridor to the canteen, and a
/// hungry one in class does not walk out of the lesson either.
/// </summary>
[Fact]
public void OutsideTheSitting_HungerFindsNoAction()
{
var (catalog, map, walks) = World();
var corridor = map.Rooms.First(room => room.Def == "Corridor").Id;
var needs = FullNeeds();
needs["Hunger"] = 0.05f;
var closed = DecisionPlanner.Decide(
catalog, map, walks,
Actor(corridor, boundToLesson: false, corridor, needs, lunchWindowOpen: false),
(_, _) => 0);
Assert.NotEqual("EatLunch", closed.Intent.ActionId);
var open = DecisionPlanner.Decide(
catalog, map, walks,
Actor(corridor, boundToLesson: false, corridor, needs, lunchWindowOpen: true),
(_, _) => 0);
Assert.Equal(GoalKind.Need, open.Intent.Kind);
Assert.Equal("EatLunch", open.Intent.ActionId);
Assert.Equal("Cafeteria", map.Rooms.First(room => room.Id == open.WalkTo).Def);
}
[Fact]
public void InsideTheSitting_EvenAPeckishPupilGoesToEat()
{
var (catalog, map, walks) = World();
var corridor = map.Rooms.First(room => room.Def == "Corridor").Id;
var needs = FullNeeds();
needs["Hunger"] = 0.6f;
var decision = DecisionPlanner.Decide(
catalog, map, walks,
Actor(corridor, boundToLesson: false, corridor, needs, lunchWindowOpen: true),
(_, _) => 0);
Assert.Equal("EatLunch", decision.Intent.ActionId);
Assert.Equal(DecisionPlanner.LunchWeight, decision.Intent.Weight);
}
[Fact]
public void ALessonOutweighsTheSitting()
{
var (catalog, map, walks) = World();
var classroom = map.Rooms.First(room => room.Def == "Classroom").Id;
var needs = FullNeeds();
needs["Hunger"] = 0.6f;
var decision = DecisionPlanner.Decide(
catalog, map, walks,
Actor(classroom, boundToLesson: true, classroom, needs, lunchWindowOpen: true),
(_, _) => 0);
Assert.Equal(GoalKind.Duty, decision.Intent.Kind);
}
private static ActorState Actor(
string node,
bool boundToLesson,
string dutyRoom,
IReadOnlyDictionary<string, float> needs,
Intent? intent = null,
bool activityActive = false) =>
bool activityActive = false,
bool lunchWindowOpen = false) =>
new(
node,
node,
@@ -220,7 +284,8 @@ public class DecisionPlannerTests
boundToLesson,
dutyRoom,
needs,
intent ?? Intent.None);
intent ?? Intent.None,
lunchWindowOpen);
private static Dictionary<string, float> FullNeeds() => new(StringComparer.Ordinal)
{