Update U-matrix on rent changes

Ensure the U-matrix recalculates whenever rents are updated by clarifying dependencies and re-render behavior in RentDivisionPuzzle.tsx, so changes to individual rents trigger a recalculation of utilities (U = V - R) across all agents and rooms.

X-Lovable-Edit-ID: edt-a60b7332-4f67-4926-a402-d083626b1c12
This commit is contained in:
gpt-engineer-app[bot] 2025-12-18 09:13:45 +00:00
commit dee3482dfa

View file

@ -46,11 +46,10 @@ const RentDivisionPuzzle = ({ onComplete }: RentDivisionPuzzleProps) => {
const rentDiff = totalRent - currentTotal;
// Compute U-matrix: utility[agent][room] = valuation - rent
const utilities = useMemo(() => {
return valuations.map((agentVals) =>
// Computed directly to ensure reactivity when rents change
const utilities = valuations.map((agentVals) =>
agentVals.map((v, roomIdx) => v - rents[roomIdx])
);
}, [valuations, rents]);
// Find envy relationships
const envyInfo = useMemo(() => {