Enhance school day structure and decision-making for lunch breaks
- 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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user