nx_accommodate.nx source
↩ module page · 59 lines · 2986 B
1// nx_accommodate.nx -- R2 of THE NISHI SITUATION-MANAGEMENT arc: the ACCOMMODATION engine. Operator:
2// "disabilities should disappear in the nishi ecosystem" -- help people with ADHD/ADD, sleep apnea, or
3// other limiters do the average things that are hard for them. The system ADAPTS to the person so the
4// disability stops being a barrier:
5// * ADHD / executive dysfunction -> ONE THING AT A TIME (a wall of tasks causes overwhelm + paralysis);
6// plus external structure (reminders) and plain language, lower activation energy.
7// * Low energy / brain fog (sleep apnea, fatigue) -> REDUCE LOAD on low-energy days; no time pressure;
8// resumable.
9// * Low vision -> large text / high contrast (UI flag).
10// Same plan, ADAPTED presentation: the engine decides HOW MANY plan items to surface and WHICH is next,
11// and emits UI-adaptation flags. Data-driven (#11): accommodation flags + the load policy are DATA, derived
12// from the person's survey answers. Pure integer logic, no floats, no hardware writes -- it adapts the
13// VIEW; the person still chooses. license_tier: ORIGINAL
14import "nx_syscalls.nx"
15
16// accommodation flags (bitwise; derived from survey answers).
17const AC_ADHD: i64 = 1 // executive dysfunction -> one-thing-at-a-time + structure
18const AC_LOW_ENERGY: i64 = 2 // fatigue / brain fog (sleep apnea) -> reduce load on low days
19const AC_LOW_VISION: i64 = 4 // -> large text / high contrast
20const AC_PLAIN_LANG: i64 = 8 // -> simplified language
21
22// set `flag` into `acc` iff a survey answer is truthy (>0). Build a profile by chaining these over answers.
23func ac_flag_if(acc: i64, answer: i64, flag: i64) -> i64 {
24 if answer > 0 { return acc + flag }
25 return acc
26}
27
28// HOW MANY plan items to surface (the core anti-overwhelm decision). ADHD -> 1 (one thing at a time);
29// low-energy scales with energy (0 low -> 1, 1 med -> 2, 2 high -> all); otherwise show all. Clamped [0,total].
30func ac_load_budget(flags: i64, energy: i64, total: i64) -> i64 {
31 var b: i64 = total
32 if (flags & AC_ADHD) != 0 { b = 1 }
33 else {
34 if (flags & AC_LOW_ENERGY) != 0 {
35 if energy <= 0 { b = 1 }
36 else { if energy == 1 { b = 2 } else { b = total } }
37 }
38 }
39 if b > total { b = total }
40 if b < 0 { b = 0 }
41 return b
42}
43
44// the single NEXT step = the first not-done step (steps are priority-ordered). -1 if all done.
45func ac_next_step(done: *i64, n: i64) -> i64 {
46 var i: i64 = 0
47 while i < n { if done[i] == 0 { return i } i = i + 1 }
48 return 0 - 1
49}
50
51// UI-adaptation flags derived from the profile.
52func ac_wants_reminder(flags: i64) -> i64 { if (flags & AC_ADHD) != 0 { return 1 } return 0 }
53func ac_wants_plain(flags: i64) -> i64 {
54 if (flags & AC_PLAIN_LANG) != 0 { return 1 }
55 if (flags & AC_ADHD) != 0 { return 1 }
56 if (flags & AC_LOW_ENERGY) != 0 { return 1 }
57 return 0
58}
59func ac_wants_large(flags: i64) -> i64 { if (flags & AC_LOW_VISION) != 0 { return 1 } return 0 }